CodeVetter · Repo Unpack · Extension points
koajs/koa
Middleware registration is the principal extension mechanism, supported by configurable composition and application-specific prototypes. Transport integration and error instrumentation are explicit API boundaries. Consumer services and parsers plug into those boundaries rather than a central route or provider registry.
- app.use(fn) is the ordered extension registry: it validates a function, appends it to middleware, and returns the application for chaining.
- options.compose replaces koa-compose and receives the middleware array when callback() is created; handleRequest expects the resulting middleware invocation to return a promise.
- app.context supports application-wide helpers such as a database reference, while createContext() supplies per-request objects inheriting that prototype.
- app.request and app.response are application-specific prototypes; new shortcut APIs must also account for the explicit delegates table on the context prototype.
- callback() is the transport adapter for consumer-created HTTP/HTTPS servers and documented Connect/Express mounting.
- Custom error behavior can use upstream try/catch middleware or app.on('error'); a caught error that is not rethrown does not reach the default error event path.
- Consumers can supply their own AsyncLocalStorage instance or replace ctx.cookies; the source and tests expose both customization seams.
- The middleware guide recommends option-taking factories and named middleware; independent middleware groups can be combined with koa-compose, and handlers can terminate downstream dispatch by omitting next().