This project is a Node.js and Express API demonstrating full CRUD functionality using file-based persistence with Node’s fs module. User data is stored in a JSON file (users.json) and persists across server restarts.
- Full CRUD operations for users
- File-based data persistence using Node.js
fs - Express routing with proper HTTP methods
- Meaningful HTTP status codes
- Error handling for invalid routes and missing resources
- Service check endpoint to confirm the server is running
GET /- Returns a confirmation message indicating the server is running
-
GET /users- Returns all users
- Status:
200 OK
-
GET /users/:id- Returns a single user by ID
- Status:
200 OK - Returns
404 Not Foundif the user does not exist
-
POST /users- Creates a new user
- Request Body (JSON):
{ "name": "User Name" } - Status:
201 Created - Returns
400 Bad Requestif required data is missing
-
PUT /users/:id- Updates an existing user by ID
- Request Body (JSON):
{ "name": "Updated Name" } - Status:
200 OK - Returns
404 Not Foundif the user does not exist - Returns
400 Bad Requestif required data is missing
-
DELETE /users/:id- Deletes a user by ID
- Status:
200 OK - Returns
404 Not Foundif the user does not exist
- Invalid or undefined routes return:
404 Not Found
- Meaningful error messages are provided for missing resources and invalid requests
All routes were tested using Postman, including:
- GET (all users and by ID)
- POST
- PUT
- DELETE
- Node.js
- Express
- JavaScript
- File System (
fs) - Postman