Skip to content

Commit

Permalink
fix(save): allow to save larger datasets
Browse files Browse the repository at this point in the history
> fix #288

The payload size limit is now configiurable via the envionment variable `PAYLOAD_SIZE_LIMIT`.
  • Loading branch information
lutangar committed Nov 28, 2023
1 parent 08aa0d8 commit 0f60e6d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions apps/backend/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
PAYLOAD_SIZE_LIMIT=20mb

# DATABASE
POSTGRES_USER=docker
POSTGRES_PASSWORD=docker
Expand Down
25 changes: 25 additions & 0 deletions apps/backend/src/environment.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
declare global {
namespace NodeJS {
interface ProcessEnv {
/**
* Controls the maximum request body size. If this is a number,
* then the value specifies the number of bytes; if it is a string,
* the value is passed to the bytes library for parsing. Defaults to '15mb'.
*/
PAYLOAD_SIZE_LIMIT?: string;
NODE_ENV?: 'development' | 'production' | string;
PORT?: string;
ADMIN_EMAIL: string;
ADMIN_PASSWORD: string;
DUMMY_EDITOR_EMAIL: string;
DUMMY_EDITOR_PASSWORD: string;
POSTGRES_HOST?: string;
POSTGRES_PORT?: string;
POSTGRES_USER?: string;
POSTGRES_PASSWORD?: string;
POSTGRES_DATABASE?: string;
}
}
}

export {};
4 changes: 2 additions & 2 deletions apps/backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ async function bootstrap() {
transform: true,
})
);
app.use(bodyParser.json({ limit: '10mb' }));
app.use(bodyParser.urlencoded({ limit: '10mb', extended: true }));
app.use(bodyParser.json({ limit: process.env.PAYLOAD_SIZE_LIMIT || '15mb' }));
app.use(bodyParser.urlencoded({ limit: process.env.PAYLOAD_SIZE_LIMIT || '15mb', extended: true }));

await app.get(MikroORM).getSchemaGenerator().ensureDatabase();
await app.get(MikroORM).getSchemaGenerator().updateSchema();
Expand Down

0 comments on commit 0f60e6d

Please sign in to comment.