diff --git a/light/test/indexTest.js b/light/test/indexTest.js index 53b7589..8c7b913 100644 --- a/light/test/indexTest.js +++ b/light/test/indexTest.js @@ -21,6 +21,7 @@ describe('index Test', () => { assert.ok(!isPath(null)); assert.ok(isPath('/tmp/date.tmp')); assert.ok(isPath('/tmp/')); + assert.ok(!isPath('date.tmp')); }); it('json from', () => { diff --git a/logger/test/sigaleTest.js b/logger/test/signaleTest.js similarity index 100% rename from logger/test/sigaleTest.js rename to logger/test/signaleTest.js diff --git a/main/baseApp.js b/main/baseApp.js index d0e4369..87c8785 100644 --- a/main/baseApp.js +++ b/main/baseApp.js @@ -6,6 +6,7 @@ import cors from 'cors'; import fs from 'fs'; import {isPath} from '@davidkhala/light/path.js'; import Multer from 'multer'; + /** * @type {string[]} minVersion: set the minimum TLS version to allow. Cannot be specified along with the secureProtocol option. * It is not recommended to use less than TLSv1.2. @@ -108,8 +109,17 @@ export const expressError = (app, onError, logger = console) => { onError(err, res); }); }; -export const formDataRouter = (cacheDir) => { - const multerCache = Multer({dest: cacheDir}); +export const formDataRouter = (cacheDir, fileSize) => { + const options = { + dest: cacheDir, + limits: {} + }; + + if (Number.isInteger(fileSize) && fileSize > 0) { + options.limits.fileSize = fileSize; // Compliant value: 8000000 + } + + const multerCache = Multer(options); return multerCache.any(); }; export const formDataFilePaths = (req, property) => {