Back to projects
Projectintermediate 8 steps ~90 min

REST API with Node

Design and build a REST API from the inside out: a router, route parameters, validation with one error shape, status codes and idempotency, cursor pagination, and finally wiring it into Express to run on your machine.

What you'll build

An inventory REST API with consistent errors, validation, and cursor pagination, running on Express.

  • Node.js
  • Express
  • REST
  • validation
  • pagination
Project briefrequirements and design decisions

Requirements

  • CRUD endpoints for a single resource
  • Validate request bodies and return clear 400 errors
  • Correct status codes: 201 on create, 404 when missing, 204 on delete

Architecture decisions

  • Routes, validation, and storage in separate modules
  • Schema validation at the boundary (parse, don't validate)
  • Consistent error response shape across endpoints

Stretch goals

  • Cursor pagination and filtering
  • Persist to SQLite or Postgres
  • OpenAPI spec and generated client types

Production checklist

  • Authentication and rate limiting
  • Structured logging and request ids
  • Integration tests against a real database

1What we're building

Frontend engineers consume APIs every day, and the best ones can design them: which URLs, which status codes, what an error looks like, how pagination works. You'll build a small inventory API, the kind behind any admin screen:

MethodPathDoesSuccess
GET/items?limit=&cursor=List items, a page at a time200
GET/items/:idGet one item200
POST/itemsCreate an item201 + Location header
PATCH/items/:idChange some fields200
DELETE/items/:idDelete an item204, no body

And for failures: 400 for invalid input (with an error for each field), 404 for unknown items or routes, 405 for a known path with the wrong method.

How this project works: the browser can't run an Express server. So you'll build the parts every framework has inside it (a router, handlers, validation, pagination) as plain functions, run them right here against simulated requests, and solve a challenge for each. In the last code step, you'll plug the same functions into real Express and run it on your machine.

That's also how good backend code is structured anyway: framework code at the edges, plain functions in the middle that you can test without starting a server.

What you'll learn: REST resource design, status codes and when each applies, route matching, validating at the boundary with a consistent error shape, why cursor pagination beats offsets, idempotency, and how to wire it all into Express.

REST API with Node project | Bloom