feat: increase upload size limit (#962)

This commit is contained in:
Jérémy M
2023-07-27 18:07:38 +02:00
committed by GitHub
parent 58530be78b
commit e90f44bbfb
5 changed files with 30 additions and 3 deletions

View File

@ -6,5 +6,6 @@ export const settings: Settings = {
'profile-picture': ['original'],
'workspace-logo': ['original'],
},
maxFileSize: '10MB',
},
};

View File

@ -9,5 +9,6 @@ export interface Settings {
imageCropSizes: {
[key in ValueOfFileFolder]?: ShortCropSize[];
};
maxFileSize: `${number}MB`;
};
}

View File

@ -1,10 +1,14 @@
import { NestFactory } from '@nestjs/core';
import { ValidationPipe } from '@nestjs/common';
import * as bodyParser from 'body-parser';
import { graphqlUploadExpress } from 'graphql-upload';
import bytes from 'bytes';
import { AppModule } from './app.module';
import { settings } from './constants/settings';
async function bootstrap() {
const app = await NestFactory.create(AppModule, {
cors: true,
@ -13,8 +17,21 @@ async function bootstrap() {
// Apply validation pipes globally
app.useGlobalPipes(new ValidationPipe());
app.use(bodyParser.json({ limit: settings.storage.maxFileSize }));
app.use(
bodyParser.urlencoded({
limit: settings.storage.maxFileSize,
extended: true,
}),
);
// Graphql file upload
app.use(graphqlUploadExpress());
app.use(
graphqlUploadExpress({
maxFieldSize: bytes(settings.storage.maxFileSize),
maxFiles: 10,
}),
);
await app.listen(3000);
}