/** * Node.js HTTP Adapter * * Converts Node.js IncomingMessage/ServerResponse to GenericRequest/GenericResponse * * @module */ import type { IncomingMessage, ServerResponse } from 'node:http'; import type { GenericRequest, GenericResponse } from '@johnhenry/aimatey-http-core'; /** * Adapter that converts Node.js IncomingMessage to GenericRequest */ export declare class NodeRequestAdapter implements GenericRequest { private req; private maxBodySize; private _parsed; private _parsePromise; constructor(req: IncomingMessage, maxBodySize?: number); /** * Parse the request body if not already parsed */ private ensureParsed; 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 Node.js request object */ get raw(): IncomingMessage; /** * Parse the request body (called by core handler before accessing body) */ parse(): Promise; } /** * Adapter that converts GenericResponse methods to Node.js ServerResponse */ export declare class NodeResponseAdapter implements GenericResponse { private res; private _statusCode; private _headersSent; constructor(res: ServerResponse); 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. * * `headersSent` belongs here and only here: once the status line is on the * wire it can no longer be changed, so a fresh response cannot begin. It is * a pre-flight concern, not a per-write one -- see isWritable(). * * Mirrors canStillRespond() in ./listener.ts, which asks the same question * of the same socket from the outer error path. */ private canStartResponse; /** * Whether the socket can still accept a write. * * Deliberately does NOT consult `headersSent`. stream() calls * sendSSEHeaders(), which flushes the headers before the first chunk, so * during a stream `headersSent` 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 loop broke before writing anything, and the * break skipped the tail, so res.end() was never reached and the connection * hung open (#89). */ isWritable(): boolean; /** * Get the underlying Node.js response object */ get raw(): ServerResponse; } //# sourceMappingURL=adapter.d.ts.map