/** * Compression middleware for HTTP responses */ import type { TCompressionAlgorithm } from '../utils/index.js'; /** * Compression configuration */ export interface ICompressionConfig { /** Enable compression (default: true) */ enabled?: boolean; /** Preferred algorithms in order (default: ['br', 'gzip']) */ algorithms?: TCompressionAlgorithm[]; /** Minimum size in bytes to compress (default: 1024) */ threshold?: number; /** Compression level (1-11 for brotli, 1-9 for gzip, default: 4 for brotli, 6 for gzip) */ level?: number; /** MIME types to compress (default: text/*, application/json, etc.) */ compressibleTypes?: string[]; /** Skip compression for these paths (glob patterns) */ exclude?: string[]; } /** * Default compression configuration */ export declare const DEFAULT_COMPRESSION_CONFIG: Required; /** * Normalize compression config from boolean or partial config */ export declare function normalizeCompressionConfig(config: ICompressionConfig | boolean | undefined): ICompressionConfig; /** * Check if response should be compressed (preliminary check) * Note: Final threshold check happens in compressResponse after buffering */ export declare function shouldCompressResponse(response: Response, request: Request, config: ICompressionConfig): boolean; /** * Select the best compression algorithm based on client and server support */ export declare function selectCompressionAlgorithm(request: Request, config: ICompressionConfig): TCompressionAlgorithm; /** * Compress a Response object * Uses buffered compression for reliability (streaming can have flushing issues) */ export declare function compressResponse(response: Response, algorithm: TCompressionAlgorithm, level?: number, threshold?: number): Promise; /** * Compress entire response body at once (for small/known-size responses) */ export declare function compressResponseBody(body: Uint8Array, algorithm: TCompressionAlgorithm, level?: number): Promise;