Skip to main content
@usenarrator/plugin-express The Express plugin reads an app as the requests it answers. Each route becomes a block that says what the handler reads from the request and what it replies with, middleware is named by what it does (“JSON body parsing”, “security headers”), and a four-parameter error handler reads as “When a request fails”.
The plugin declares library: { name: "express", versions: ">=4 <6" } and reads Express 4 and 5, including the Express 5 path syntax. It only narrates files that import or require Express or belong to a package that depends on it (see Dependency detection), so a Map#get or another library’s app.get is left alone.

Examples

The hello-world app
English
A route with middleware and error handling
English
Middleware and an error handler
English

What it covers

  • Apps and routers: express(), express.Router(), app.route(path) chains, app.listen, settings such as app.set and app.disable, and mounting routers with app.use(path, router).
  • Routes: every HTTP method and all, route-level middleware (“after auth”), and one-line handlers that read inline.
  • Middleware: the built-in express.json, express.urlencoded and express.static, common packages such as cors, helmet, morgan, cookie-parser, compression, express-rate-limit and express-session by what they do, inline middleware around next(), and error handlers.
  • The request: path and query parameters, headers, the body and cookies.
  • The response: send, json, status, sendStatus, redirect, render, cookies, headers, downloads and files, and next(err).

Translating

The English phrasebook is exported as en and typed as ExpressPhrases.