A small in-memory to-do list API built with Node.js and Express — the FlyRank Backend Track Week 2 assignment (Build your first CRUD API).
A REST API that lets you create, read, update and delete tasks. Data lives only in memory (a plain array in index.js) — it resets whenever the server restarts. There is no database yet; that's next week.
npm install
npm startThe server starts on http://localhost:3000.
| Method | Path | Meaning |
|---|---|---|
| GET | / |
API info |
| GET | /health |
Health check |
| GET | /tasks |
List all tasks (supports ?done=true|false and ?search=text) |
| GET | /tasks/:id |
Get a single task |
| POST | /tasks |
Create a task ({ "title": "..." }) |
| PUT | /tasks/:id |
Update a task's title and/or done |
| DELETE | /tasks/:id |
Delete a task |
| GET | /stats |
Task counts: { total, done, open } |
| POST | /reset |
Restore the 3 seed tasks |
Status codes: 200 reads, 201 create, 204 delete, 400 invalid body, 404 unknown id — every error comes back as { "error": "..." }.
Interactive docs are served at http://localhost:3000/docs, generated from openapi.json. Use "Try it out" to run the full CRUD cycle without curl.
$ curl -i -X POST http://localhost:3000/tasks -H "Content-Type: application/json" -d '{"title":"Buy milk"}'
HTTP/1.1 201 Created
Content-Type: application/json; charset=utf-8
{"id":4,"title":"Buy milk","done":false}
Beyond the required CRUD cycle:
- Filtering:
GET /tasks?done=truereturns only finished tasks. - Search:
GET /tasks?search=milkreturns tasks whose title contains the word (case-insensitive). - Stats:
GET /statsreturns{ total, done, open }. - Reset:
POST /resetrestores the 3 seed tasks — handy after a demo or the mortality experiment below.
Create a task, restart the server, then GET /tasks again — the new task is gone; only the 3 seed tasks remain. Data lives in a JavaScript array in the server's memory, so it only survives as long as the Node process does. This is exactly why real apps need a database: anything you want to persist across restarts has to live outside the process.