/** * Shared HTTP request-body helpers used by gateway/api.ts and the per-domain * router modules. Error responses written here are tiny * (well under the compression threshold), so plain uncompressed JSON writes * are behaviour-identical to route-helpers.ts's compressing json() helper. */ import type { IncomingMessage as HttpRequest, ServerResponse } from "node:http"; /** Signals that a request body exceeded the per-handler size cap. */ export declare class BodyTooLargeError extends Error { constructor(); } export interface ReadBodyOpts { /** Hard cap on bytes accepted from the stream; rejects with BodyTooLargeError when exceeded. */ maxBytes?: number; } export interface ReadJsonBodyOpts extends ReadBodyOpts { /** Treat an empty/whitespace-only body as `{ ok: true, body: null }` instead of a 400. */ allowEmpty?: boolean; /** Route-specific fixed body for JSON syntax/duplicate-key rejection. */ invalidJsonResponse?: unknown; invalidJsonStatus?: number; /** Reject ambiguous duplicate top-level object members. */ rejectDuplicateTopLevelKeys?: boolean; /** Route-specific fixed body for an exceeded maxBytes limit. */ tooLargeResponse?: unknown; } export declare function readBody(req: HttpRequest, opts?: ReadBodyOpts): Promise; export declare function readBodyRaw(req: HttpRequest): Promise; export declare function readJsonBody(req: HttpRequest, res: ServerResponse, opts?: ReadJsonBodyOpts): Promise<{ ok: true; body: unknown; } | { ok: false; }>; //# sourceMappingURL=http-helpers.d.ts.map