import type { Request, Response } from 'express'; import type { TransformResponseHook } from '../../server.ts'; import type { ResponseWriter } from './ResponseWriter.ts'; import { HttpResponse } from './responses.ts'; export interface ExpressResponseWriterOptions { /** Applied to every response before it is written (`transformResponse`). */ transform?: TransformResponseHook; /** Told when `transform` throws or returns no response; the original is sent. */ onTransformError?: (message: string) => void; } /** * Renders `HttpResponse` values through Express, so JSON, text and bytes get * the same serialization, `ETag` and conditional-GET handling as `res.json` / * `res.send`. Headers the request already carries (security headers, CORS) * stay: a descriptor header replaces one of the same name, except * `set-cookie` (appended) and `vary` (merged). A write that fails before * anything is sent (a body `JSON.stringify` rejects, a stream that fails * before its first chunk) restores the status and headers it found, so the * error response that follows carries none of the descriptor's. */ export declare class ExpressResponseWriter implements ResponseWriter { #private; constructor(options?: ExpressResponseWriterOptions); write(response: HttpResponse, req: Request, res: Response): Promise; } /** * @internal A response that will not be sent: an unread Node stream body is * destroyed; one being read keeps running, but its error cannot crash. */ export declare function releaseUnsentBody(response: HttpResponse): void;