From 448d8d3bad94ea40b00900a711449b1d7e3e4cea Mon Sep 17 00:00:00 2001 From: "Robert St. John" Date: Wed, 21 Aug 2024 14:24:03 -0600 Subject: [PATCH] refactor(service): users typescript/di: remove unreferenced factory function from upload middleware export --- service/src/upload.ts | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/service/src/upload.ts b/service/src/upload.ts index 2e6f9e22b..85ee97831 100644 --- a/service/src/upload.ts +++ b/service/src/upload.ts @@ -6,26 +6,21 @@ import env from './environment/env' const storage = multer.diskStorage({ destination: env.tempDirectory, - filename: function(req, file, cb: any) { + filename: function(req, file, cb: (error: Error | null, filename: string) => void): void { crypto.pseudoRandomBytes(16, function(err, raw) { if (err) { - return cb(err); + return cb(err, '') } - cb(null, raw.toString('hex') + path.extname(file.originalname)); - }); + cb(null, raw.toString('hex') + path.extname(file.originalname)) + }) } -}); +}) -function Upload(limits: multer.Options['limits'] = {}) { - return multer({ - storage, limits - }); +function UploadMiddleware(limits: multer.Options['limits'] = {}): multer.Multer { + return multer({ storage, limits }) } -const defaultHandler = Upload() - -const upload = { - Upload, defaultHandler -} +const defaultHandler = UploadMiddleware() +const upload = Object.freeze({ defaultHandler }) export = upload