import { type ZlibOptions, type BrotliOptions, type ZstdOptions } from 'node:zlib'; import type { APIGatewayProxyEvent, Context } from 'aws-lambda'; import type { Express, Request, Response } from 'express'; import type { Writable } from 'stream'; interface ExpressRequest extends Request { apiGateway?: { event: APIGatewayProxyEvent; context: Context; }; } interface ExpressResponse extends Response { flushable?: boolean; } /** * Configuration options for response compression. * * @property enabled - Whether compression is enabled. Set to false to disable compression entirely. * Defaults to true (compression enabled). * @property encoding - The compression encoding to use ('br', 'zstd', 'gzip', 'deflate'). * If not specified, the best encoding will be negotiated based on Accept-Encoding header. * @property options - Compression library options. This can include any of the options accepted by * zlib, Brotli, or Zstd, as defined in the zlib library, and will be passed * directly to the corresponding compression library. */ export interface CompressionConfig { enabled: boolean; encoding?: 'br' | 'zstd' | 'gzip' | 'deflate'; options?: ZlibOptions | BrotliOptions | ZstdOptions; } type AsyncHandlerFunction = (event: APIGatewayProxyEvent, context: Context) => Promise; /** * Creates a Lambda Adapter that wraps an Express app and supports response streaming * for API Gateway v1 proxy integration using AWS Lambda response streaming * * @param app - Express application instance * @param responseStream - AWS Lambda response stream * @param compressionConfig - Optional compression configuration * @returns Lambda handler function */ export declare function createStreamingLambdaAdapter(app: Express, responseStream: Writable, compressionConfig?: CompressionConfig): AsyncHandlerFunction; /** * Converts API Gateway event to Express-compatible request object * Creates a proper IncomingMessage-like object with stream properties */ export declare function createExpressRequest(event: APIGatewayProxyEvent, context: Context): ExpressRequest; /** * Creates Express-compatible response object that properly extends ServerResponse * * This function creates a response object that: * - Supports AWS Lambda response streaming via HttpResponseStream * - Automatically compresses responses based on Accept-Encoding header * - Uses negotiator to select the best available encoding (br, zstd if available, gzip, deflate) * - Uses compressible package to determine if content should be compressed * * Compression flow: * 1. Check Accept-Encoding header and select best encoding * 2. Create HttpResponseStream with metadata * 3. If compression is applicable, create compression stream and pipe to httpResponseStream * 4. Write data to compression stream (or httpResponseStream if no compression) * 5. End compression stream, which automatically ends httpResponseStream * * @param responseStream - The AWS Lambda response stream * @param method - The HTTP method (GET, POST, etc.) * @param request - Optional Express request object (used to check Accept-Encoding header) * @returns Express-compatible response object */ export declare function createExpressResponse(responseStream: Writable, event: APIGatewayProxyEvent, context: Context, request?: ExpressRequest, compressionConfig?: CompressionConfig): ExpressResponse; export {};