1lazy router
2routing flags
5HTTP verb helpers
1final handler
01
1Receive
APP
Create
The Router
The Express application object waits until routing is needed, then creates a Router using the app routing settings.
application setup
GET
Lazy router property
app.init defines a router getter; the Router is constructed only after code first reads app.router.
CFG
Route flags copied
case sensitive routing and strict routing settings are passed into the Router constructor.
DEF
Defaults already set
defaultConfiguration prepares x-powered-by, weak etags, query parsing, views, trust proxy, and environment behavior before routes run.
application setup
OK
Router is not eager Simple app setup does not allocate the route stack until routing APIs need it.
i
Settings shape routing The Router sees the app-level strict and case-sensitive flags at creation.
02
2Register
API
Attach
Middleware
Express keeps the public API small by proxying app.use and app.route calls into the Router implementation.
registration gates
1
app.use delegates Middleware registration flattens arguments and forwards layers into the application router.
USE
2
app.route creates route Route registration is a thin proxy that returns Router#route for the requested path.
RTE
3
app.param extends router Parameter callbacks attach to the router so matched route params can be processed consistently.
PAR
Small surface
Application methods stay as delegators while router owns dispatch details.
Order matters
Middleware and routes run in the order they are attached.
03
3Dispatch
HTTP
Handle
The Request
At runtime the app hands the Node request and response to the router, with finalhandler ready to close unresolved paths or errors.
dispatch result
REQ 01
Node server enters app
The Express app is callable by node:http, so requests land on the application handler.
RUN 02
Router walks layers
The router evaluates middleware, mounted routers, params, and matching route handlers.
FIN 03
finalhandler closes gaps
Unmatched requests and propagated errors can be converted into a final HTTP response.
dispatch result
Response payload
OK
Works as middleware
Mounted apps inherit request and response prototypes from parent apps.
i
Errors keep moving
The dispatch model is built around next-style propagation.
Requestdispatch result
No raw secretsexample content stays public-safe