Skip to content

Commit

Permalink
feat: increase request body size limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Romsters committed Mar 27, 2024
1 parent 8af454e commit d9a2816
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import helmet from "helmet";
import { NestFactory } from "@nestjs/core";
import { SwaggerModule, DocumentBuilder } from "@nestjs/swagger";
import { ConfigService } from "@nestjs/config";
import { NestExpressApplication } from "@nestjs/platform-express";
import { configureApp } from "./configureApp";
import { getLogger } from "./logger";
import { AppModule } from "./app.module";
import { AppMetricsModule } from "./appMetrics.module";

const BODY_PARSER_SIZE_LIMIT = "10mb";

async function bootstrap() {
const logger = getLogger(process.env.NODE_ENV, process.env.LOG_LEVEL);

Expand All @@ -15,8 +18,9 @@ async function bootstrap() {
process.exit(1);
});

const app = await NestFactory.create(AppModule, {
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
logger,
rawBody: true,
});
const configService = app.get(ConfigService);
const metricsApp = await NestFactory.create(AppMetricsModule);
Expand All @@ -32,6 +36,8 @@ async function bootstrap() {
SwaggerModule.setup("docs", app, document);
}

app.useBodyParser("json", { limit: BODY_PARSER_SIZE_LIMIT });
app.useBodyParser("urlencoded", { limit: BODY_PARSER_SIZE_LIMIT, extended: true });
app.enableCors();
app.use(helmet());
configureApp(app);
Expand Down

0 comments on commit d9a2816

Please sign in to comment.