🇺🇸 English |
🇧🇷 Português |
Video | Technologies | About | Routes | Middlewares | Cloning | Contact
dev-burger-order-log-API-video.mp4
If the video has any errors, reload the page!
Access the project online HERE
Watching the video above and/or accessing the project online will help you understand the explanation!
This project is the API of CodeBurger, a web application that performs the registration and management of orders for a hamburger shop, serving as the basis for its Interface that I developed essentially in ReactJS.
-
POST /order
: This route receives the customer's order, the customer's name, and the order amount. This information is passed by thebody
of the request, and based on it a new request is registered inside an array, in the following format:{ id: "ac3ebf68-e0ad-4c1d-9822-ff1b849589a8", order: "X- Salada, 2 batatas grandes, 1 coca-cola", clientName:"José", price: 44.50, status: "Em preparação" }
The id
and status
information is generated in the system and incorporated in the request. The ids are generated using the uuid
library, and the status is always 'In preparation' when an order is placed.
This route also has a special check to prevent orders with incomplete data from being made.
-
GET /order
: This route lists all orders already placed, displaying the ones inside the array. -
GET /order/:id
: Based on theid
sent, this route returns a specific request. -
PUT /order/:id
: Based on theid
sent, this route can change an order, which could be one or all of the order data (except theid
andstatus
, of course). -
PATCH /order/:id
: Based on theid
sent, once called this route changes the status of the received order to "Ready". -
DELETE /order/:id
: Based on theid
sent, once called, delete the received order.
When calling the POST /order
route passing { order: "X- Salad, 2 large potatoes, 1 coke", clienteName:"José", price: 44.50 }
, the array looks like this:
[
{
id: 'ac3ebf68-e0ad-4c1d-9822-ff1b849589a8',
order: 'X- Salada, 2 batatas grandes, 1 coca-cola',
clienteName: 'José',
price: 44.5,
status: 'Em preparação'
}
];
When calling the PATCH /order/ac3ebf68-e0ad-4c1d-9822-ff1b849589a8
route, the array looks like this:
[
{
id: 'ac3ebf68-e0ad-4c1d-9822-ff1b849589a8',
order: 'X- Salada, 2 batatas grandes, 1 coca-cola',
clienteName: 'José',
price: 44.5,
status: 'Pronto'
}
];
-
checkIdExistence
: Its function is to check if the received ID exists and to take action if it does not. It is used on all routes that are given an ID. -
showMethodNUrl
: Its function is to show the method (GET,POST,PUT,DELETE, etc) on the console and also the url of the request. It is used in all requests. -
verifyClientData
: Its function is to verify the customer data sent by thebody
, and take action if this request intends to modify data that the customer does not have permission to.
To clone and run this project on your computer you will need Git, Node.js v16.13.2 or higher, and preferably an API Client such as Insomnia (but can also be accessed through the browser) previously installed.
In the terminal:
# Clone this repository with:
> git clone https://github.com/Luk4x/dev-burger-order-log-API.git
# Enter the repository with:
> cd dev-burger-order-log-API
# Install dependencies with:
> npm i
# Run the project with:
> npm run server
# Once this is done, you will be able to access the project through the link that will appear in the terminal! (something like http://localhost:3000/ or http://127.0.0.1:5173/)
Vitrine.Dev 🪟
|
Lucas Maciel
|