Skip to content

Commit

Permalink
refactor(service): users typescript/di: remove unreferenced factory f…
Browse files Browse the repository at this point in the history
…unction from upload middleware export
  • Loading branch information
restjohn committed Aug 21, 2024
1 parent f637dfa commit 448d8d3
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions service/src/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 448d8d3

Please sign in to comment.