Express is a minimal Node.js web framework that maps HTTP methods and paths to handlers and composes middleware functions over request, response, and next to build an ordered request-processing pipeline.
In simpler words
Express gives Node an HTTP routing and middleware model. Each request moves through matching functions until one sends a response or passes control onward.
Nest uses Express (or Fastify) as its HTTP platform adapter. Learn the raw request flow first so Nest modules, guards, and pipes map to something concrete.
Define routes with method + path and return JSON responses
Order middleware for parsing, logging, auth, and errors
Read req.params, req.query, and req.body safely
Explain what Nest adds on top of Express routing
Routes and handlers
Definition
An Express route binds an HTTP method and path pattern to a handler function that receives request and response objects and may call next to delegate control.
In simpler words
app.get, app.post, app.patch, and app.delete register handlers. Handlers should stay thin and delegate business logic to services.
Path parameters live in req.params; query strings in req.query; JSON bodies in req.body after body-parsing middleware runs.
Set the status code explicitly for creates and errors. Return JSON with res.json or res.status(...).json(...).
A handler that throws without an error boundary can crash the process unless async errors are forwarded with next(error).
This is the shape Nest controllers reproduce with decorators, DTO validation, and dependency injection.
Middleware order and error handling
Definition
Express middleware is a function (req, res, next) registered in order; each piece may end the response, mutate the request, or call next() to continue the chain.
In simpler words
Order matters: parsers and correlation IDs first, auth before protected routes, and error middleware after routes.
Global middleware such as express.json() should run before route handlers that read req.body.
Route-specific middleware can enforce authentication before a handler executes.
A four-argument error handler (err, req, res, next) formats failures consistently — the same role AllExceptionsFilter plays in apps/api.