A simple RESTful API for managing users with Node.js and Express.
🔗 GitHub Repository: https://github.com/Basant1Saini/user-api-assignment
- Node.js installed on your computer
- VS Code (Visual Studio Code)
- Thunder Client extension for VS Code
- Open terminal in this folder
- Install dependencies:
npm install- Start the server:
npm start- You should see:
Server running on http://localhost:3000
GET http://localhost:3000/users
Returns a list of all users.
GET http://localhost:3000/users/1
Returns the user with ID 1.
POST http://localhost:3000/user
Content-Type: application/json
{
"firstName": "Arjun",
"lastName": "Patel",
"hobby": "Photography"
}
Creates a new user.
PUT http://localhost:3000/user/1
Content-Type: application/json
{
"hobby": "Yoga"
}
Updates user with ID 1. You can update any field.
DELETE http://localhost:3000/user/3
Deletes the user with ID 3.
- Open VS Code
- Click Extensions icon (or press
Cmd+Shift+X) - Search for "Thunder Client"
- Click "Install"
- Click the Thunder Client icon in the left sidebar (⚡)
- Click "New Request" button
- Select method: GET
- Enter URL:
http://localhost:3000/users - Click Send
- You should see 3 users in the response
- Take a screenshot
- Select method: GET
- Enter URL:
http://localhost:3000/users/1 - Click Send
- You should see Anshika's details
- Take a screenshot
- Select method: POST
- Enter URL:
http://localhost:3000/user - Click on Body tab
- Select JSON format
- Paste this:
{
"firstName": "Arjun",
"lastName": "Patel",
"hobby": "Photography"
}- Click Send
- You should get status 201 Created
- Take a screenshot
- Select method: POST
- Enter URL:
http://localhost:3000/user - In Body tab (JSON), paste:
{
"firstName": "Arjun"
}- Click Send
- You should get status 400 Bad Request with error message
- Take a screenshot
- Select method: PUT
- Enter URL:
http://localhost:3000/user/1 - In Body tab (JSON), paste:
{
"hobby": "Yoga"
}- Click Send
- You should see updated user with new hobby
- Take a screenshot
- Select method: DELETE
- Enter URL:
http://localhost:3000/user/3 - Click Send
- You should get confirmation that Priya was deleted
- Take a screenshot
- Select method: DELETE
- Enter URL:
http://localhost:3000/user/999 - Click Send
- You should get status 404 Not Found
- Take a screenshot
user-api/
├── server.js # Main file with all the code
├── package.json # Project info and dependencies
└── README.md # This file
- All 5 CRUD operations (Create, Read, Update, Delete)
- Request logging (see console when requests come in)
- Input validation (checks if data is correct)
- Error handling (friendly error messages)
- In-memory storage (data stored in array)
Server Tips:
- Server must be running to test the API
- Use
Ctrl+Cto stop the server - Check the terminal for request logs
- All data is lost when you restart the server (in-memory storage)
Thunder Client Tips:
- Save your requests by clicking the Save button (give it a name like "Get All Users")
- Create a collection called "User API" to organize all requests
- Use the History tab to see previous requests
- Take clear screenshots showing: URL, Method, Body (if applicable), and Response