feat: increase upload size limit (#962)
This commit is contained in:
@ -6,5 +6,6 @@ export const settings: Settings = {
|
||||
'profile-picture': ['original'],
|
||||
'workspace-logo': ['original'],
|
||||
},
|
||||
maxFileSize: '10MB',
|
||||
},
|
||||
};
|
||||
|
||||
@ -9,5 +9,6 @@ export interface Settings {
|
||||
imageCropSizes: {
|
||||
[key in ValueOfFileFolder]?: ShortCropSize[];
|
||||
};
|
||||
maxFileSize: `${number}MB`;
|
||||
};
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user