A beginner-friendly backend project built with Node.js and Express, using an in-memory database (array of objects).
The goal is to practice RESTful API design, CRUD operations, error handling, and basic problem-solving.
-
Add a task
- Endpoint:
POST /tasks - Input (JSON):
{ "title": "Buy milk" } - Output (JSON):
{ "id": 1, "title": "Buy milk", "completed": false }
- Endpoint:
-
Get all tasks
- Endpoint:
GET /tasks - Output: Array of tasks.
- Endpoint:
-
Get one task by ID
- Endpoint:
GET /tasks/:id - Behavior: Return a single task if found.
- Error: Return
404if the task does not exist.
- Endpoint:
-
Update a task
- Endpoint:
PUT /tasks/:id - Input (JSON):
{ "title": "Buy almond milk", "completed": true } - Behavior: Update only provided fields.
- Error: Return
404if the task does not exist.
- Endpoint:
-
Delete a task
- Endpoint:
DELETE /tasks/:id - Behavior: Remove the task.
- Error: Return
404if the task does not exist.
- Endpoint:
- Store tasks in an array (no external DB).
- Each task should have:
{ "id": number, "title": string, "completed": boolean }
-
Search/filter tasks
- Example:
GET /tasks?completed=true→ returns only completed tasks.
- Example:
-
Validation
- Don’t allow empty titles in tasks.
- Return a
400 Bad Requesterror if input is invalid.
-
Reset route
- Endpoint:
DELETE /reset - Clears all tasks and resets ID counter.
- Useful for testing and starting fresh.
- Endpoint: