/** The shared HTTP transport and compressed-request output retain Bun's 128 MiB plain-body default. * Source: bun-types/serve.d.ts, ServeOptions.maxRequestBodySize (@default 1024 * 1024 * 128), * https://github.com/oven-sh/bun/blob/main/packages/bun-types/serve.d.ts . * A pack's descriptor.maxRequestBodySize overrides both the transport and decoded-output limits. */ export const DEFAULT_MAX_DECODED_REQUEST_BODY_SIZE = 128 * 1024 * 1024; export class RequestBodyTooLargeError extends Error { constructor() { super('Payload Too Large'); this.name = 'RequestBodyTooLargeError'; } } export const oversizedBody = (): Response => new Response('Payload Too Large', { status: 413 }); export const decodedBodyLimit = (declared?: number): number => declared ?? DEFAULT_MAX_DECODED_REQUEST_BODY_SIZE;