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.
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:
| Method | Path | Does | Success |
|---|---|---|---|
| GET | /items?limit=&cursor= | List items, a page at a time | 200 |
| GET | /items/:id | Get one item | 200 |
| POST | /items | Create an item | 201 + Location header |
| PATCH | /items/:id | Change some fields | 200 |
| DELETE | /items/:id | Delete an item | 204, 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.