import type { INestApplication } from '@nestjs/common';
import { json, urlencoded } from 'express';

export const DEFAULT_HTTP_BODY_LIMIT = '10mb';

export function configureHttpBodyParsers(
  app: Pick<INestApplication, 'use'>,
  limit = process.env.HTTP_BODY_LIMIT || DEFAULT_HTTP_BODY_LIMIT,
) {
  app.use(json({ limit }));
  app.use(urlencoded({ extended: true, limit }));
}
