CodeVetter · Repo Unpack · Feature catalog
koajs/koa
Koa's user-facing surface is a developer API for composing HTTP behavior. Request helpers interpret URLs and headers, while response helpers construct and transmit representations. Cookies, errors, and current-context access complement that core; the documented framework leaves routing to middleware.
- app.use(fn) validates functions and supports chaining; async or promise-returning middleware can await next() and modify the response during upstream unwinding.
- Request APIs expose mutable method, URL, path, query, querystring, and search, alongside original-URL-based href and memoized WHATWG URL.
- accepts(), acceptsEncodings(), acceptsCharsets(), and acceptsLanguages() negotiate headers through accepts; is(), type, charset, and length interpret request content metadata.
- host/hostname, protocol/secure, ips/ip, and subdomains provide proxy-aware request identity; fresh/stale evaluate conditional GET or HEAD requests against outgoing validators.
- Response bodies accept strings, buffers, JSON values, Node streams, ReadableStream, Blob, and Response, with type/status/length handling and HEAD or empty-status suppression.
- Response helpers implement redirect(), back(), attachment(), MIME type assignment, ETag/Last-Modified, Vary, header get/set/append/remove, and flushHeaders().
- ctx.cookies exposes get/set options including signing and security attributes; ctx.throw/ctx.assert and exported createHttpError/HttpError/isHttpError supply HTTP error utilities.
- app.currentContext exposes the current request when AsyncLocalStorage is enabled; raw response handling can be selected with ctx.respond=false, while routing is explicitly external middleware.