import type { AgentServer } from './server.js'; /** The part of Node's `IncomingMessage` the adapter reads. */ export interface NodeRequestLike { /** HTTP method. */ method?: string; /** Request path, with its query string. */ url?: string; /** Request headers, as Node reports them. */ headers: Record; /** Subscribes to `data`, `end`, `error`, and `close`. */ on(event: string, listener: (chunk?: unknown) => void): unknown; /** Stops reading the body. */ destroy?(error?: Error): unknown; } /** The part of Node's `ServerResponse` the adapter writes. */ export interface NodeResponseLike { /** Writes the status line and headers. */ writeHead(status: number, headers?: Record): unknown; /** Writes a chunk of the body. */ write(chunk: Uint8Array | string): unknown; /** Ends the response. */ end(chunk?: Uint8Array | string): unknown; /** Subscribes to `close`, so a disconnected client aborts the handler. */ on(event: string, listener: () => void): unknown; /** Flushes headers on platforms that buffer them, so an event stream starts immediately. */ flushHeaders?(): unknown; } /** Options for the Node adapter. */ export interface NodeListenerOptions { /** Origin used to build the request URL, for routes that read the query string. Defaults to the Host header. */ origin?: string; /** Receives errors the adapter itself could not answer, such as a write to a closed socket. */ onError?: (error: unknown) => void; } /** * Adapts the server to Node's `http`, and to anything that speaks its request and response objects. * * `http.createServer(toNodeListener(server))` serves it directly; Express and Fastify take the same * function as middleware (`app.use(...)`, or `fastify.use(...)` with `@fastify/middie`), and a Nest * controller can call it from a route handler. Streaming responses are piped through unbuffered, so * an event stream reaches the client as it is produced. */ export declare function toNodeListener(server: AgentServer, options?: NodeListenerOptions): (request: NodeRequestLike, response: NodeResponseLike) => void;