Build a real, typed REST API with Express 5 the hands-on way: 9 test-driven blocks in strict TypeScript, validated with Zod, tested with Node's built-in
node:testrunner. ~1.5–2 weeks.
You don't read about Express — you implement routes, middleware, and handlers, make failing tests pass, and type every handler properly. From block 05 you build a REST API for a simple domain (tasks / notes / bookmarks), in memory, growing to a capstone.
🧩 Third in a series: TypeScript in a Month · Node.js in a Month · Express in the Small.
- 🧪 Test-driven — every block ships failing tests; you make them green by hitting a
real app with
fetch. - 🔒 Strict TypeScript — typed handlers via
RequestHandler<Params, ResBody, ReqBody, Query>and Zod-inferred types. - 🧱 Express 5 — modern routing and automatic async error handling.
- ✅ Verified solutions — every reference answer is itself tested
(
npm run test:solutions). - 🛠️ Project-driven — fundamentals lead into a multi-resource REST API.
git clone https://github.com/Rossoline/express-learn.git
cd express-learn
npm install # Node 22+ required
npm test # most fail until you solve the exercises
npm run typecheckWork a block, then run just its tests:
node --import tsx --test "blocks/01-getting-started/tests/*.test.ts"
npm run play blocks/01-getting-started/src/examples.tsThe full plan is in PLAN.md.
| Part | Blocks |
|---|---|
| Fundamentals | 01 Getting Started · 02 Routing · 03 Middleware & lifecycle · 04 Request & Response (typed handlers) |
| REST · validation · errors | 05 REST & the tasks resource · 06 Validation with Zod · 07 Error handling |
| Project | 08 Multi-resource API (capstone) · 09 Testing & polish (stretch) |
blocks/NN-topic/
├── README.md # the topic explained, with examples and the exercise list
├── src/examples.ts # a runnable worked example
├── src/exercises.ts # practice tasks with // TODO stubs — your job
├── tests/ # node:test tests (real fetch) — make them pass
└── solutions/ # reference solutions (try the exercises first!)
| Command | What it does |
|---|---|
npm test |
Run every block's tests. |
npm run typecheck |
Type-check the whole project. |
npm run test:solutions |
Verify the reference solutions all pass. |
npm run play <file> |
Run any .ts file with tsx. |
If this helped you learn Express, please ⭐ the repo. Happy routing! 🚂