🇺🇸 English |
🇧🇷 Português |
Video | Technologies | About | Routes | Middlewares | Cloning | Contact
user-register-API.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 Users API, a web application that performs the registration and management of users, serving as the basis for its Interface that I developed essentially in ReactJS.
-
POST /users
: This route is given the user's name and age. this information is passed by thebody
of the request, and based on it a new user is registered in an array, in the following format:{ name: "Lucas", age: 18, id: "06d5e912-d672-49ca-92c9-5a4e0e470f15" }
The
id
information is generated in the system by theuuid
library and incorporated into the user.
This route also has a check to prevent users with incomplete data from being registered. -
GET /users
: This route lists all users registered in the array. -
GET /users/:id
: Based on theid
sent, this route returns a specific user. -
PUT /users/:id
: Based on theid
sent, this route can change one or all of a user's data (except theid
). -
DELETE /users/:id
: Based on theid
sent, delete the user who owns it.
- When calling the
POST /users
route twice, passing{ name: "Hana", age: 23 }
throughbody
, the array looks like this:
[
{
name: "Hana",
age: 23,
id: "05a5913e-h325-da2a-75c9-93f20e02fa19"
},
{
name: "Hana",
age: 23,
id: "e671f3a7-4d0a-4c44-b850-c16ab6785e89"
}
];
- When calling the
GET /users/e671f3a7-4d0a-4c44-b850-c16ab6785e89
route, the return is:
{
name: "Hana",
age: 23,
id: "e671f3a7-4d0a-4c44-b850-c16ab6785e89"
};
-
checkUserId
: Its function is to check if the received ID exists and take action if it doesn't. It is used on all routes that are given an ID. -
showMethodNUrl
: Its function is to show in the console the method (GET,POST,PUT,DELETE, etc) and also the url of the request. It is used in all requests and is only intended to facilitate and organize development. -
verifyUserData
: Its function is to verify the user data sent by thebody
, and take action if this request intends to modify data that the user 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, Yarn, 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/user-register-API.git
# Enter the repository with:
> cd user-register-API
# Install dependencies with:
> yarn install
# Run the project with:
> yarn app
# 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:3001/ or http://127.0.0.1:5173/)
Vitrine.Dev 🪟
|
Lucas Maciel
|