Skip to content

Instantly share code, notes, and snippets.

@croraf
Last active February 24, 2019 01:02
Show Gist options
  • Save croraf/6954b41966452a926400988e45b6543c to your computer and use it in GitHub Desktop.
Save croraf/6954b41966452a926400988e45b6543c to your computer and use it in GitHub Desktop.
orderme app - backend functionalities
Backend, once its interfaces (check https://gist.github.com/croraf/ee7017bdda3e3c65881936173df2cbc9) get initialized on startup (src/index.js file),
is message driven.
Meaning everything that happens is a consequence of receiving a REST message on REST endpoints.
(https://order1.herokuapp.com/swagger)
Therefore, several functionalities can be defined depending on the REST messages received.
As described in interfaces document, each of these messages get processed through 3 layers.
Checking the above swagger URL following functionalities can be seen:
1. CRUD on restaurants
Business layer just forwards these actions towards DAL layer and database.
2. CRUD on users
Business layer just forwards these actions towards DAL layer and database.
3. CRUD on orders (with the cancel action)
Business layer forwards these actions towards DAL layer and database.
The creation of order sets the timer during which the restaurant has to accept or cancel the order.
If it expires before response, the order is canceled. During this time the user can also cancel its order.
Acceptance sets another timer during which the user can still cancel the order. On this second timer expiration the accepted order is considered confirmed by the user.
During that timer the cancel action can come on cancel endpoint, canceling the order.
Cancel action can also come during
that actually modifies the specific order to set its status to CANCELED)
4. authentication
This functionality is designed to receive the token the user has been given by the third party authentication service
(as per OAuth2 standard), verify it with the authentication service, generate JWT token that will include some user data,
and return this JWT token to the user.
Currently the data stored in JWT is only some data gotten during verification from authentication service.
(TODO:) The user should use this token in an HTTP header in each request on functionality that requires authentication.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment