This repository comes with methods for adding, updating, deleting, and displaying users to manage user management. Each addition creates a unique key with uuidv4, which is assigned under an object with its corresponding values. You can use the unique id generated by uuidv4 to perform subsequent add, delete, update, and display operations.
To set up the project, follow these steps:
- Copy the .env.example file and rename it to .env.
- Edit the properties in the .env file as follows:
- Set the APP_NAME property to your application name.
- Set the APP_PORT property to the port you want your application to run on.
To use the User Management API, follow these steps:
- Install the required dependencies by running
npm install
. - Copy the
.env.example
file and rename it to.env
. - Open the
.env
file and set the following values:
APP_NAME=your_app_name
APP_PORT=your_app_port
-
Start the server by running
npm start
. -
To add a new user(s):
/users/insert/:prop=:val;:prop2=:val2;..
/users/insert/:prop=:val;:prop2=:val2;../:prop3=:val3;:prop4=:val4;../..
Examples:
/users/insert/username=JohnDoe;password=123456
/users/insert/username=JohnDoe;password=123456;country=US/username=MarryJane;password=987654;[email protected];phone=555-55-55-555
Responses:
{
"91cfda5f-dc12-43d0-91d5-215e0616bc82":{
"username":"JohnDoe",
"password":"123456",
"country":"US"
},
"7aef0ba8-f166-4b23-9cc1-d5ade5ce0ef4":{
"username":"MarryJane",
"password":"987654",
"email":"[email protected]",
"phone":"555-55-55-555"
}
}
- To get a list of all users:
/users
Response:
{
"91cfda5f-dc12-43d0-91d5-215e0616bc82":{
"username":"JohnDoe",
"password":"123456",
"country":"US"
},
"7aef0ba8-f166-4b23-9cc1-d5ade5ce0ef4":{
"username":"MarryJane",
"password":"987654",
"email":"[email protected]",
"phone":"555-55-55-555"
}
}
- To get a specific user by ID:
/users/:id
Example:
/users/91cfda5f-dc12-43d0-91d5-215e0616bc82
Response:
{
"username":"JohnDoe",
"password":"123456",
"country":"US"
}
- To delete a user by ID(s):
/users/:id/delete
or use this but response has all users
/users/delete/:id/:id2/:id3/..
- To delete a user's property:
/users/:id/delete/:prop
Example:
/users/91cfda5f-dc12-43d0-91d5-215e0616bc82/delete/country
Response:
{
"username":"JohnDoe",
"password":"123456"
}
- To update a user's property:
/users/:id/update/:prop/:val
or use this but response has all users
/users/update/:id/:prop=:val;:prop2=:val2;..
Example:
/users/91cfda5f-dc12-43d0-91d5-215e0616bc82/update/password/321456
Response:
{
"username":"JohnDoe",
"password":"321456",
"country":"US"
}
- To get a user's property:
/users/:id/:prop
or
/users/:id/show/:prop
Example:
/users/91cfda5f-dc12-43d0-91d5-215e0616bc82/username
Response:
{"username":"JohnDoe"}
Note: Remember to replace your_app_name
and your_app_port
with your actual application name and port number.