import type { NestExpressApplication } from '@nestjs/platform-express'; const express = require('express') as { json(options: { limit: string; verify(request: { rawBody?: Buffer }, response: unknown, buffer: Buffer): void; }): (...args: unknown[]) => unknown; }; export const DEFAULT_JSON_BODY_LIMIT = '2mb'; export const IMPORT_JSON_BODY_LIMIT = '25mb'; export function configureHttpBodyParsers(app: NestExpressApplication) { // Import preview/confirmation temporarily carries the source CSV/TSV in // JSON. Give only these endpoints the larger boundary; keeping ordinary // JSON at 2 MiB limits the duplicate raw-buffer + parsed-object footprint. app.use('/api/client/send/imports', express.json({ limit: IMPORT_JSON_BODY_LIMIT, verify(request, _response, buffer) { request.rawBody = buffer; }, })); app.useBodyParser('json', { limit: DEFAULT_JSON_BODY_LIMIT }); app.useBodyParser('urlencoded', { limit: DEFAULT_JSON_BODY_LIMIT, extended: true }); }