This is a simple REST API built with Express.js to manage users. It allows you to create, read, update, and delete users.
- Retrieve a list of users
- Add a new user
- Update an existing user
- Delete a user
-
Clone the repository:
git clone <repository_url> cd <repository_folder>
-
Install dependencies:
npm install
-
Start the server:
npm start
The server will run on
http://localhost:3000.
GET /user
- Returns a list of all users.
POST /user
- Request body (JSON):
{ "name": "John Doe", "nationality": "USA" } - Response:
{ "message": "User added successfully", "newUser": { "id": 3, "name": "John Doe", "nationality": "USA" } }
PUT /user/:id
- Request body (JSON):
{ "name": "Updated Name", "nationality": "Updated Nationality" } - Response:
{ "message": "User updated successfully", "updatedUser": { "id": 1, "name": "Updated Name", "nationality": "Updated Nationality" } }
DELETE /user/:id
- Response:
{ "message": "User deleted successfully" }
- Node.js
- Express.js