Code Monkey home page Code Monkey logo

api's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar duffleit avatar kremat avatar thomaseizinger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

api's Issues

Move balance calculation from the frontend to the backend

Currently, we return bills and debts to the frontend. However, in addition to the debts, the frontend also shows the balances of each participant. This information is not present in the API response and hence, the frontend needs to calculate it by itself.

This is:

  1. error prone: the frontend is written in JS and has barely and tests
  2. inconsistent in terms of responsibilities: the frontend should focus on design and UX, not on doing math

In addition, we recently introduced property-based tests into the backend to have more thorough tests and better guarantees that our optimization algorithms actually behave correctly.
For these tests, we already calculate the balances of each participant because no matter how we optimize the debts, the balances always need to stay the same: they are the perfect metric to check on whether an optimization algorithm is correct.
However, at the moment, all this logic is part of the test suite and not the production code.
If we return balances in the API we can:

  1. Move this code to the production code and thereby support it properly (this will clean up the tests quite a bit)
  2. Remove some math from the frontend

Implement endpoint for returning domain-specific status

Currently, there is no way too request configuration options from the API. It would be good to have an endpoint that returns stuff like:

  • what is the current optimizer for new nobts
  • whether the API is using an in-memory db or connected to a real database

Note that this is different from an actual healthcheck endpoint that would return information about the connected database. A healthcheck endpoint is out-of-scope of this issue.

Change API to reflect naming of the frontend

Initially, we thought "expenses" and "transactions" are good terms. But they are not :D

We should add new endpoints to the API that use our newly adopted terminology so that the frontend doesn't have to do that much mapping in its presentation code.

Terminology to be changed:

  • expenses -> bills
  • transactions -> debts

Fix error in documentation about currencyInformation

Currently, the documentation states the following about the currencyInformation object:

An object defining the conversion information to the currency of the associated nobt. If this object is present, the amounts of this expense are to be interpreted in the given currency. If this object is not present, it is assumed that the currency of this expense is equal to the currency of the nobt, hence the conversion rate is 1.

This is not correct.
The amounts listed in the shares are always in the currency of the nobt. The conversion information object represents the rate and the original currency. Clients can utilize this object to store information about the amounts that were entered by the user:

  • the original currency
  • the rate the client used to convert the entered amounts into the nobt currency

Refactor from ZonedDateTime to Instant

The timestamps for createdOn should actually be Instant and not ZonedDateTime.

From the documentation of Instant:

This class models a single instantaneous point on the time-line. This might be used to record event time-stamps in the application.

Allow bills to be deleted

The API should allow to delete bills from a nobt, however, they should not be actually deleted from the DB but instead "marked" deleted with a flag or something like that. During the debt-calculation, these bills have to be filtered out.

Also, the API should advertise to the client that bills can be deleted. I would suggest adding a link to each bill's resource payload like this:

{
	"id": 3,
	"name": "Beer",
        // other properties
	"_links": {
		"delete": {
			"href": "..."
		}
	}
}

For now, this link is always present. Later on, we can change whether or not bills can be deleted by excluding the links under certain conditions (e.g. time-limit etc)

Provide links for creating expenses and payments

Currently, the client knows the endpoints for creating expenses and payments. We should add links to the response of a Nobt that points clients to these endpoints.

{
	"id": "g943hNß57gha",
	...
	"_links": {
		"create-expense": {
			"href": "..."
		},
		"create-payment": {
			"href": "..."
		}
	}
}

Implementation hints can be taken from the "delete" link of expenses. See #8.

Better sanitization of inputs from the frontend

Problem

This incident is a combination of several problems, with one of them being a trailing space in the name "Blair".

Goal

Avoid errors as soon as possible.

Recommendation

Sanitize the input from the frontend better, especially all "name" fields. We should remove any whitespace character from the front and back of all names.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.