All topics / Express From Zero

Express From Zero

Learn the minimalist web framework that defined Node.js backends: routing, the middleware chain that is Express's whole personality, the request and response objects, building a REST API, error handling, serving and structuring an app, and testing and production. Small core, middleware for everything else.

  1. What Express Is & Your First Server Express is the minimalist Node.js web framework — a thin layer over the built-in http module. Install it, write a tiny server, run it, and meet the one idea: the middleware chain.
  2. Routing How Express turns a method and a path into a handler: method routes, route params via req.params, query strings via req.query, modular routers, and why route order decides which handler wins.
  3. Middleware Middleware is the (req, res, next) function chain that is Express's whole personality: read or modify, respond, or call next. Covers ordering, built-in and third-party middleware, and attaching data to req.
  4. Request & Response Read input from req (params, query, body, headers), write output with res (status + json), pick honest status codes, and validate untrusted input before you ever touch it.
  5. Building a REST API Assemble routing, middleware, and request/response validation into a full CRUD REST API: a tasks resource with five route handlers on one Router, an in-memory store, and the right status codes.
  6. Error Handling Express routes errors to a special four-argument middleware registered last. Covers next(err), a custom AppError class, the async-error trap (Express 4 vs 5), the asyncHandler wrapper, and a 404 catch-all.
  7. Serving & Structuring an App Grow the one-file tasks API into a real shape: serve static files, split by responsibility into routes/controllers/services, separate app-building from server-starting, and read config from the environment.
  8. Testing & Production Test the tasks API in memory with supertest and a runner, then harden it for production: env config, helmet/cors/compression/rate-limit, graceful shutdown, and a reverse proxy.
  9. Where to Go Next What you can build now, how Express compares to Fastify, NestJS, and bare node:http, the Express 5 async-error win, the ecosystem you'll reach for, and one concrete thing to go build.