This project is an Express.js API that provides endpoints for managing user data.
- Clone the repository.
- Install dependencies using
npm install
. - Run the server using
npm run dev
.
- Description: Displays a welcome message.
- Response: "Welcome to server"
- Description: Retrieves a list of users as HTML.
- Response: Returns a list of users in HTML format.
- Description: Retrieves a list of users as JSON.
- Response: Returns a list of users in JSON format.
- Description: Retrieves a user by ID.
- Parameters:
- id: User ID
- Response: Returns user data matching the provided ID.
- Description: Retrieves a user by ID using query parameters.
- Parameters:
- id: User ID
- Response: Returns user data matching the provided ID.
- Description: Creates a new user.
- Request Body: JSON object containing user data.
- Response: Returns a success message upon successful creation.
- Description: Updates an existing user.
- Request Body: JSON object containing user data.
- Response: Returns a success message upon successful update.
- Description: Partially updates an existing user.
- Request Body: JSON object containing updated user data.
- Response: Returns a success message upon successful update.
- Description: Deletes a user by ID.
- Parameters:
- id: User ID
- Response: Returns a success message upon successful deletion.
# Retrieve list of users
curl http://localhost:4000/api/users
# Retrieve user by ID
curl http://localhost:4000/api/users/1
# Create new user
curl -X POST -H "Content-Type: application/json" -d '{"first_name":"John","last_name":"Doe"}' http://localhost:4000/api/users
# Update user
curl -X PUT -H "Content-Type: application/json" -d '{"id":1, "first_name":"Jane"}' http://localhost:4000/api/users
# Delete user by ID
curl -X DELETE http://localhost:4000/api/users/1