feat: request increase body size limit to 1mb

This commit is contained in:
Ali BARIN
2023-01-29 12:29:56 +00:00
parent 85a3558074
commit 078ea24cd2
3 changed files with 7 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
import createError from 'http-errors';
import express from 'express';
import appConfig from './config/app';
import cors from 'cors';
import corsOptions from './config/cors-options';
import morgan from './helpers/morgan';
@@ -26,6 +27,7 @@ appAssetsHandler(app);
app.use(morgan);
app.use(
express.json({
limit: appConfig.requestBodySizeLimit,
verify(req, res, buf) {
(req as IRequest).rawBody = buf;
},
@@ -33,6 +35,7 @@ app.use(
);
app.use(express.urlencoded({
extended: false,
limit: appConfig.requestBodySizeLimit,
verify(req, res, buf) {
(req as IRequest).rawBody = buf;
},

View File

@@ -31,6 +31,7 @@ type AppConfig = {
bullMQDashboardUsername: string;
bullMQDashboardPassword: string;
telemetryEnabled: boolean;
requestBodySizeLimit: string;
};
const host = process.env.HOST || 'localhost';
@@ -89,6 +90,7 @@ const appConfig: AppConfig = {
webAppUrl,
webhookUrl,
telemetryEnabled: process.env.TELEMETRY_ENABLED === 'false' ? false : true,
requestBodySizeLimit: '1mb',
};
if (!appConfig.encryptionKey) {

View File

@@ -1,6 +1,7 @@
import express, { Router } from 'express';
import multer from 'multer';
import { IRequest } from '@automatisch/types';
import appConfig from '../config/app';
import webhookHandler from '../controllers/webhooks/handler';
const router = Router();
@@ -9,6 +10,7 @@ const upload = multer();
router.use(upload.none());
router.use(express.text({
limit: appConfig.requestBodySizeLimit,
verify(req, res, buf) {
(req as IRequest).rawBody = buf;
},