Lab Assignment 2 – Web Dev III (Node.js & Express)
- Name: Harsh Dev Jha
- Roll No: 2501010168
A lightweight RESTful API built with Node.js and Express.js to manage student records using in-memory JSON data, modular routing, custom logging middleware, and status code handling.
├── data/
│ └── students.js # In-memory student array dataset
├── middleware/
│ └── logger.js # Custom request logging middleware
├── routes/
│ └── studentRoutes.js # Express Router for student CRUD routes
├── app.js # Express app initialization & server setup
├── test-api.js # Automated test script
├── package.json # Dependencies and scripts
└── README.md # Documentation
npm installnpm startServer runs on http://localhost:3000.
node test-api.js| Method | Endpoint | Description | Status Codes |
|---|---|---|---|
| GET | /students |
Retrieve all student records | 200 |
| GET | /students/:id |
Retrieve single student by ID | 200, 404 |
| POST | /students |
Create a new student record | 201, 400 |
| PUT | /students/:id |
Update an existing student | 200, 400, 404 |
| DELETE | /students/:id |
Remove student record by ID | 200, 404 |
{
"id": 4,
"name": "Harsh Dev Jha",
"course": "BCA"
}{
"name": "Harsh Dev Jha",
"course": "BTech"
}