Express Notes REST API
Build your first REST API with Node.js and Express: a small service for text notes that lets you create, list, read, update and delete notes by sending HTTP requests. Notes are kept in memory in an array, so you can focus completely on how APIs work before adding a database. You'll check the input, return the right status codes (such as 201 when something is created and 404 when it doesn't exist), and send errors in one consistent format. You'll learn how HTTP methods map to actions, Express routing and middleware, reading JSON request bodies, REST conventions, and testing an API with automated tests.
- Estimate
- ~7.5h
- Steps
- 6
- Completed by
- 0
- Proposed by
- codeseed.app
Node.js · Express
Project roadmap
- 01
Set up Express
~1hCreate a project with npm init, install express, and write server.js that uses express.json() to read JSON bodies and listens on a port from an environment variable (default 3000). Add GET /health returning { status: "ok" }. Add a start script and use node --watch while developing. Done when: curl localhost:3000/health returns the JSON.
- 02
List and create notes
~1.5hStore notes in an array, each with an id (from crypto.randomUUID()), title, content, createdAt and updatedAt. Add GET /notes, returning all notes newest first, and POST /notes, creating a note and returning it with status 201. Add GET /notes/:id, returning 404 with an error message when not found. Done when: notes created with curl appear in the list and can be fetched by id.
- 03
Update and delete notes
~1hAdd PUT /notes/:id to replace a note's title and content (updating updatedAt), and DELETE /notes/:id returning 204. Both return 404 for unknown ids. Done when: notes can be updated and deleted, and unknown ids return 404.
- 04
Validate input and handle errors
~1.5hWrite a validation middleware for POST and PUT: the title is a required string of 1 to 100 characters, and the content is a string of at most 10,000 characters. Return 400 with { error: { message, fields } } for invalid input and for malformed JSON. Add a 404 handler for unknown routes and a final error handler that returns 500 without internal details. Done when: every error comes back in the same format.
- 05
Add search
~1hSupport GET /notes?q=word to find notes whose title or content contains the word (ignoring case), and ?limit= to limit the number of results (1 to 100). Validate the query parameters. Done when: search returns only matching notes.
- 06
Test the API
~1.5hExport the app separately from the code that starts the server, then write tests with Node's built-in test runner (node --test) or Vitest, plus supertest, covering every endpoint: success cases, 404s, validation errors, malformed JSON and search. Done when: npm test passes.
Resources
Ready to build this?
Get a GitHub repo and start building. Your AI reviewer checks each step as you go.
Tech stack