CodeVetter · Repo Unpack · System map
koajs/koa
The runtime centers on an EventEmitter-based Application and three linked HTTP wrapper prototypes. Consumers instantiate the library and choose their server and middleware stack. Packaging, CI, and publishing are separate from request execution.
- package.json identifies koa 3.2.1, requires Node >=18, resolves CommonJS to lib/application.js, and resolves ESM to generated dist/koa.mjs.
- Application extends EventEmitter; its constructor owns middleware, settings, and application-specific context/request/response prototypes.
- listen() wraps callback() in http.createServer(); callback() can also be supplied to consumer-created HTTP or HTTPS servers.
- createContext() connects the Node req/res pair to context, request, and response wrappers, records originalUrl, and creates a fresh state object.
- Request handling delegates middleware composition to koa-compose, completion detection to on-finished, and response streaming to Node Stream.pipeline.
- The core state boundary is request-local ctx.state and optional AsyncLocalStorage; the documented database integration is a consumer-supplied app.context.db reference.
- npm scripts provide node --test, c8 coverage, Standard linting, and gen-esm-wrapper building; prepare invokes the build, and published files include dist and lib.
- CI installs, lints, measures coverage, and uploads to Codecov; a separate tag/manual workflow installs and publishes to npm with id-token permission.