From 24e100bd7be8bf20778bdf2767aa35cae8d7e502 Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Fri, 5 Apr 2024 11:31:43 +0200 Subject: [PATCH] fix: changing the chunk size needed an app restart --- backend/src/main.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/src/main.ts b/backend/src/main.ts index f985a3ef..b77d01cd 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -8,6 +8,7 @@ import { NestExpressApplication } from "@nestjs/platform-express"; import { DocumentBuilder, SwaggerModule } from "@nestjs/swagger"; import * as bodyParser from "body-parser"; import * as cookieParser from "cookie-parser"; +import { NextFunction, Request, Response } from "express"; import * as fs from "fs"; import { AppModule } from "./app.module"; import { ConfigService } from "./config/config.service"; @@ -20,12 +21,13 @@ async function bootstrap() { const config = app.get(ConfigService); - app.use( + app.use((req: Request, res: Response, next: NextFunction) => { + const chunkSize = config.get("share.chunkSize"); bodyParser.raw({ type: "application/octet-stream", - limit: `${config.get("share.chunkSize")}B`, - }), - ); + limit: `${chunkSize}B`, + })(req, res, next); + }); app.use(cookieParser()); app.set("trust proxy", true);