A restaurant management API in Express.js that uses MongoDB as a database and Redis as session store. A basic frontend is written in EJS.
Schema Validations to endpoints are done using JOI
Prepend /restaurants to access the following routes
Get info about all the restaurants, for an index page
Add a restaurant.
Will add data only if a user registered as a restaurant admin is logged in.
This endpoint can be accessed only is the user logged in is a restaurant admin.
Get info about a specific restaurant.
Update info about a specific restaurant.
Will append data only if the restaurant's admin is logged in.
Delete a specific restaurant.
Will delete data only if the restaurant's admin is logged in.
Get info about a specific restaurant's revenue.
Will send a result only if the restaurant's admin in logged in.
Add an item to a restaurant.
Will add data only if a user registered as a restaurant admin is logged in.
Remove an item from a restaurant.
Will add data only if a user registered as a restaurant admin is logged in.
Get info about a specific restaurant's active orders.
Will send a result only if the restaurant's admin in logged in.
Get info about a specific restaurant's past orders.
Will send a result only if the restaurant's admin in logged in.
Update the status of an active order.
The status can only be update sequentially : Received -> Confirmed -> Cooking -> Done
Will send a result only if the restaurant's admin in logged in.
Cancel an active order.
Upon cancellation, the order amount will be refunded to the customer.
Will delete data only if the restaurant's admin is logged in.
Prepend /user to access the following routes
Validates the provided credentials and logs the user in.
Creates a new user and logs the user in.
For Google OAuth using PassportJS.
Validates the provided credentials and logs the user in.
Creates a new user and logs the user in.
For Google OAuth using PassportJS.
Get basic info and cart items of the currently active user.
This endpoint can be accessed only is the user logged in is a client.
Add an item to the currently active user's cart.
Items from multiple restaurants cannot be added to the same cart.
This endpoint can be accessed only is the user logged in is a client.
Update quantity of an item in the currently active user's cart.
This endpoint can be accessed only is the user logged in is a client.
Delete an item from the currently active user's cart.
This endpoint can be accessed only is the user logged in is a client.
Add funds to the currently active user's wallet.
This endpoint can be accessed only is the user logged in is a client.
Place an order for the items in the user's cart.
Will work only if the user's wallet funds are sufficient for the order.
This endpoint can be accessed only is the user logged in is a client.
Get info about the currently active orders of the currently active user.
This endpoint can be accessed only is the user logged in is a client.
Get info about the past orders of the currently active user.
This endpoint can be accessed only is the user logged in is a client.
Get the current status of an active order.
Will send a response only if the user who made the order is logged in.
This endpoint can be accessed only is the user logged in is a client.
Remove an active order.
This is possible only if the order's status is Received/Confirmed
Upon cancellation, the order amount will be refunded to the customer.
Will delete only if the user who made the order is logged in.
Add a review to a restaurant.
Will add a review only if the currently active user has at least one completed order from the restaurant.
This endpoint can be accessed only is the user logged in is a client.
Remove a review from a restaurant.
Will delete data only if the restaurant's admin is logged in.
Logs the active user out.
Add the following to your .env
file.
PORT
COOKIE_EXPIRY_TIME
JWT_EXPIRY_TIME
JWT_SECRET_KEY
SESSION_SECRET_KEY
DATABASE_URL
GOOGLE_PASSPORT_ID
GOOGLE_PASSPORT_SECRET
GOOGLE_PASSPORT_CLIENT_CALLBACKURL
GOOGLE_PASSPORT_RESADMN_CALLBACKURL
MAIL_ID
MAIL_PASS
MONGO_INITDB_ROOT_USERNAME
MONGO_INITDB_ROOT_PASSWORD
MAIL_HOST
The workspace can be accessed in this public collection :
https://elements.getpostman.com/redirect?entityId=19312206-561647fd-c7d4-49d6-ab55-144e25662c2c&entityType=collection