/** * Koa HTTP Adapter * * Converts Koa Context to GenericRequest/GenericResponse * * @module */ import type { Context } from 'koa'; import type { GenericRequest, GenericResponse } from '@johnhenry/aimatey-http-core'; /** * Adapter that converts Koa Context to GenericRequest */ export declare class KoaRequestAdapter implements GenericRequest { private ctx; constructor(ctx: Context); get method(): string; get url(): string; get headers(): Record; get body(): any; get params(): Record | undefined; get query(): Record | undefined; get ip(): string | undefined; /** * Get the underlying Koa context object */ get raw(): Context; } /** * Adapter that converts GenericResponse methods to Koa Context */ export declare class KoaResponseAdapter implements GenericResponse { private ctx; private _statusCode; private _headersSent; constructor(ctx: Context); status(code: number): void; header(name: string, value: string): void; send(data: any): void; stream(generator: AsyncGenerator): Promise; /** * Whether a *new* response can still be started on this socket. * * `headerSent` is a pre-flight concern: once the status line is out it can * no longer be changed, so a fresh response cannot begin. It says nothing * about whether the socket will take another write -- see isWritable(). */ private canStartResponse; /** * Whether the socket can still accept a write. * * Deliberately does NOT consult `headerSent`. stream() calls * sendSSEHeaders(), which flushes the headers before the first chunk, so * during a stream `headerSent` is the expected state rather than a reason * to stop. Folding it in here made the per-chunk guard in stream() false on * its very first iteration -- the same defect reported against the Node * adapter in #89, which this adapter shares because it drives the same * ServerResponse through the same SSE helpers. * * `ctx.writable` is Koa's own liveness getter: false once the underlying * response has ended or its socket is gone. */ isWritable(): boolean; /** * Get the underlying Koa context object */ get raw(): Context; } //# sourceMappingURL=adapter.d.ts.map