This folder provides a mock REST API using json-server for frontend-only candidates. It simulates a real backend without requiring you to implement the actual backend logic.
-
Install dependencies:
cd mock-api npm install -
Start the mock API server:
npm start
The mock API will run on http://localhost:3001
json-server automatically creates RESTful endpoints based on db.json:
Retrieve all tasks
curl http://localhost:3001/tasksRetrieve a single task by ID
curl http://localhost:3001/tasks/1Create a new task
curl -X POST http://localhost:3001/tasks \
-H "Content-Type: application/json" \
-d '{
"title": "New Task",
"description": "Task description",
"status": "todo",
"createdAt": "2026-02-18T12:00:00.000Z"
}'Note: The exact fields required will be explained by the invigilator. The above is just an example.
Update entire task (replace)
curl -X PUT http://localhost:3001/tasks/1 \
-H "Content-Type: application/json" \
-d '{
"id": "1",
"title": "Updated Task",
"description": "Updated description",
"status": "in-progress",
"createdAt": "2026-02-18T10:00:00.000Z"
}'Update partial task fields
curl -X PATCH http://localhost:3001/tasks/1 \
-H "Content-Type: application/json" \
-d '{"status": "done"}'Delete a task
curl -X DELETE http://localhost:3001/tasks/1json-server provides filtering, sorting, and pagination:
# Get tasks with status "todo"
http://localhost:3001/tasks?status=todo
# Get tasks with status "in-progress"
http://localhost:3001/tasks?status=in-progress# Sort by createdAt in descending order
http://localhost:3001/tasks?_sort=createdAt&_order=desc# Get page 1 with 10 items per page
http://localhost:3001/tasks?_page=1&_limit=10Changes made through the API are automatically saved to db.json. The file updates in real-time as you create, update, or delete tasks.
- IDs are auto-generated when you POST without an id
- Data persists between server restarts (saved to db.json)
- The server has CORS enabled by default
- It returns proper HTTP status codes (200, 201, 404, etc.)
- The initial
db.jsononly contains minimal structure - you must design the complete task schema based on requirements
When building your Angular frontend:
- Set your API base URL to
http://localhost:3001 - Use Angular's
HttpClientto make requests - Create a service to handle all API calls
- Implement proper error handling
- Handle loading states
Good luck! 🚀