A simple REST API built with Node.js and Express for managing user data. This project demonstrates basic CRUD operations and can serve as a starting point for learning backend development.
- Create a User: Add a new user to the database.
- Read Users:
- Retrieve all users.
- Retrieve a specific user by their ID.
- Update a User: Modify details of an existing user.
- Delete a User: Remove a user from the database.
Before running this project, make sure you have:
Here are the available API endpoints:
GET /users
Retrieves a list of all users.
POST /users
Adds a new user to the database.
Request Body:
{
"firstName": "John",
"lastName": "Doe",
"age": 30
}
Response:
User with name John added to the database
GET /users/:id
Retrieves a specific user by their unique ID.
Response:
{
"id": "1234-5678-9012",
"firstName": "John",
"lastName": "Doe",
"age": 30
}
PATCH /users/:id
Updates details of a specific user.
Request Body (optional fields):
{
"firstName": "Jane",
"lastName": "Smith",
"age": 25
}
Response:
The user with ID 1234-5678-9012 is updated successfully
DELETE /users/:id
Removes a user from the database.
Response:
The user with ID 1234-5678-9012 was successfully deleted
- Add input validation to ensure required fields are present.
- Include error handling for non-existent users.
- Enhance the project with a database integration.