The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
feat: increase upload size limit (#962)
Jérémy Me90f44bbfb4b
diff --git a/server/package.json b/server/package.jsonindex 8a592862a17..998aa985bc6 100644--- a/server/package.json+++ b/server/package.json@@ -51,6 +51,8 @@"apollo-server-express": "^3.12.0","axios": "^1.4.0","bcrypt": "^5.1.0",+ "body-parser": "^1.20.2",+ "bytes": "^3.1.2","class-transformer": "^0.5.1","class-validator": "^0.14.0","date-fns": "^2.30.0",@@ -82,6 +84,7 @@"@nestjs/schematics": "^9.0.0","@nestjs/testing": "^9.0.0","@types/bcrypt": "^5.0.0",+ "@types/bytes": "^3.1.1","@types/date-fns": "^2.6.0","@types/express": "^4.17.13","@types/graphql-upload": "^8.0.12",diff --git a/server/src/constants/settings/index.ts b/server/src/constants/settings/index.tsindex e62f4a81546..b4d9c22e081 100644--- a/server/src/constants/settings/index.ts+++ b/server/src/constants/settings/index.ts@@ -6,5 +6,6 @@ export const settings: Settings = {'profile-picture': ['original'],'workspace-logo': ['original'],},+ maxFileSize: '10MB',},};diff --git a/server/src/constants/settings/interfaces/settings.interface.ts b/server/src/constants/settings/interfaces/settings.interface.tsindex f7240f0b25e..472c3b3b55a 100644--- a/server/src/constants/settings/interfaces/settings.interface.ts+++ b/server/src/constants/settings/interfaces/settings.interface.ts@@ -9,5 +9,6 @@ export interface Settings {imageCropSizes: {[key in ValueOfFileFolder]?: ShortCropSize[];};+ maxFileSize: `${number}MB`;};}diff --git a/server/src/main.ts b/server/src/main.tsindex 950726a6218..5174c526d9d 100644--- a/server/src/main.ts+++ b/server/src/main.ts@@ -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 globallyapp.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);}diff --git a/server/yarn.lock b/server/yarn.lockindex 0653b1d939a..e483ddf10d7 100644--- a/server/yarn.lock+++ b/server/yarn.lock@@ -2649,6 +2649,11 @@"@types/connect" "*""@types/node" "*"+"@types/bytes@^3.1.1":+ version "3.1.1"+ resolved "https://registry.yarnpkg.com/@types/bytes/-/bytes-3.1.1.tgz#67a876422e660dc4c10a27f3e5bcfbd5455f01d0"+ integrity sha512-lOGyCnw+2JVPKU3wIV0srU0NyALwTBJlVSx5DfMQOFuuohA8y9S8orImpuIQikZ0uIQ8gehrRjxgQC1rLRi11w==+"@types/connect@*":version "3.4.35"resolved "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz"@@ -3853,7 +3858,7 @@ [email protected]:type-is "~1.6.18"unpipe "1.0.0"[email protected], body-parser@^1.19.0, body-parser@^1.20.0:[email protected], body-parser@^1.19.0, body-parser@^1.20.0, body-parser@^1.20.2:version "1.20.2"resolved "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz"integrity sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==@@ -3973,7 +3978,7 @@ busboy@^1.0.0:dependencies:streamsearch "^1.1.0"[email protected], bytes@^3.1.2:version "3.1.2"resolved "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz"integrity sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==