Welcome! You've inherited a small REST API for managing tasks, written by another developer. QA has filed a few bug reports, and product has requested a new endpoint. Your job is to ship the fixes and the new feature.
Time: 45 minutes Stack: Node.js, Express, SQLite (in-memory)
- From this repo on GitHub, click the green Code button → Codespaces tab → Create codespace on main.
- Wait about 45 seconds while the environment boots and dependencies install automatically.
- In the Codespace terminal, run:
npm start
- A notification will appear that port 3000 has been forwarded. You can either open the forwarded URL in a new browser tab, or test the API directly from the same Codespace terminal with
curl(examples below).
A task has this shape:
{
"id": 1,
"title": "Buy groceries",
"description": "Milk, eggs, bread",
"completed": 0,
"created_at": "2026-05-22 14:30:00"
}Existing endpoints:
| Method | Path | Description |
|---|---|---|
| GET | /tasks |
List all tasks. Optional ?completed=true or false |
| GET | /tasks/:id |
Get a single task |
| POST | /tasks |
Create a task. Body: { "title": "...", "description": "..." }. Title required. |
| PATCH | /tasks/:id |
Update any subset of fields |
| DELETE | /tasks/:id |
Delete a task |
QA has reported three issues. Reproduce each one, then fix it.
- Filtering doesn't work.
GET /tasks?completed=truereturns an empty array even though some tasks are clearly completed. - Missing tasks return 200.
GET /tasks/9999(a non-existent id) returns200 OKwith an empty body. It should return404 Not Found. - Bad input crashes the server.
POST /taskswith notitlereturns a500 Internal Server Error. It should return400 Bad Requestwith a helpful error message.
Product wants every task to have a priority level. Implement this in three steps:
- Update the schema. Add a
prioritycolumn to thetaskstable. It must be one of"low","medium", or"high", and default to"medium"when not provided. The existing seed data should still load without errors. - Accept it on create. Update
POST /tasksso callers can optionally include apriorityfield in the request body. Reject invalid values with400 Bad Request. - Add a new endpoint.
GET /tasks/by-priority/:levelshould return all tasks at that priority level. Return400 Bad Requestif:levelisn't one of the three valid values.
Open the Shell tab in Replit (or a second terminal) and use curl:
# List all tasks
curl http://localhost:3000/tasks
# Filter — should return only completed
curl "http://localhost:3000/tasks?completed=true"
# Get one
curl http://localhost:3000/tasks/1
# Get a missing one — should be 404
curl -i http://localhost:3000/tasks/9999
# Create
curl -X POST -H "Content-Type: application/json" \
-d '{"title":"New task","description":"Notes"}' \
http://localhost:3000/tasks
# Create with missing title — should be 400
curl -i -X POST -H "Content-Type: application/json" \
-d '{}' http://localhost:3000/tasks
# Create with a priority
curl -X POST -H "Content-Type: application/json" \
-d '{"title":"Urgent task","priority":"high"}' \
http://localhost:3000/tasks
# Create with an invalid priority — should be 400
curl -i -X POST -H "Content-Type: application/json" \
-d '{"title":"Bad","priority":"urgent"}' \
http://localhost:3000/tasks
# List by priority (your new endpoint)
curl http://localhost:3000/tasks/by-priority/high
# Invalid priority level — should be 400
curl -i http://localhost:3000/tasks/by-priority/urgentThe -i flag prints the HTTP status, which is helpful for verifying 404 / 400 responses.