From 2e433c3233d53e1bee998d0d80ff9f3407d9ca3a Mon Sep 17 00:00:00 2001 From: Kilian Decaderincourt Date: Wed, 1 Dec 2021 17:16:54 +0100 Subject: [PATCH] feat: add body size limit config as env var --- README.md | 6 ++---- src/raw-parser.middleware.ts | 5 ++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4b1a129..0b4e2a4 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,6 @@ It can be used with [kiliandeca/excalidraw-fork](https://gitlab.com/kiliandeca/e | --------------- | ------------------------------------------------------------ | ---------------- | | `PORT` | Server listening port | 8080 | | `GLOBAL_PREFIX` | API global prefix for every routes | `/api/v2` | -| `STORAGE_URI` | [Keyv](https://github.com/jaredwray/keyv) connection string | `""` (in memory) | +| `STORAGE_URI` | [Keyv](https://github.com/jaredwray/keyv) connection string, example: `redis://user:pass@localhost:6379`. Availabe Keyv storage adapter: redis, mongo, postgres and mysql | `""` (in memory **non-persistent**) | | `LOG_LEVEL` | Log level (`debug`, `verbose`, `log`, `warn`, `error`) | `warn` | - - -Availabe Keyv storage adapter: redis, mongo, postgres and mysql +| `BODY_LIMIT` | Payload size limit for scenes or images | `50mb` | diff --git a/src/raw-parser.middleware.ts b/src/raw-parser.middleware.ts index 970ccde..9e7742e 100644 --- a/src/raw-parser.middleware.ts +++ b/src/raw-parser.middleware.ts @@ -4,7 +4,10 @@ import { hasBody } from 'type-is'; // Excalidraw Front end doesn't send a Content Type Header // so we tell raw parser to check if there is a body -const rawParserMiddleware = raw({ type: hasBody }); +const rawParserMiddleware = raw({ + type: hasBody, + limit: process.env.BODY_LIMIT ?? '50mb', +}); @Injectable() export class RawParserMiddleware implements NestMiddleware {