Merge pull request #986 from Tria-plc/freight_feature/usermanagement

update body-parser implementation to use Nest's API and improve depe…
This commit is contained in:
marshal
2026-07-28 09:34:01 +03:00
committed by GitHub

View File

@@ -2,7 +2,7 @@ import "reflect-metadata";
import * as dotenv from "dotenv";
dotenv.config();
import { NestFactory } from "@nestjs/core";
import { json, urlencoded } from "express";
import type { NestExpressApplication } from "@nestjs/platform-express";
import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger";
import {
HttpExceptionFilter,
@@ -21,10 +21,16 @@ import { AppModule } from "./app.module";
const JSON_BODY_LIMIT = '20mb';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const app = await NestFactory.create<NestExpressApplication>(AppModule);
app.use(json({ limit: JSON_BODY_LIMIT }));
app.use(urlencoded({ limit: JSON_BODY_LIMIT, extended: true }));
// Nest's own body-parser API, NOT `app.use(json(...))` from express: express
// is not a declared dependency of this app (it arrives under
// @nestjs/platform-express), so importing it directly resolved only through
// pnpm's hoisted dev store and died as MODULE_NOT_FOUND in the production
// image, where `pnpm deploy --prod` installs declared dependencies only.
// This also RECONFIGURES the default parsers rather than racing them.
app.useBodyParser('json', { limit: JSON_BODY_LIMIT });
app.useBodyParser('urlencoded', { limit: JSON_BODY_LIMIT, extended: true });
// Dev CORS: reflect any localhost origin and allow credentials so the
// freight portal (5173), passenger portal (5174), backoffices (5183/5184)