Improved a few small logs

pull/29/head
tycrek 3 years ago
parent 91df02b176
commit f4d67e8b94
No known key found for this signature in database
GPG Key ID: 25D74F3943625263

@ -23,15 +23,17 @@ const router = express.Router();
router.post('/', (req, res, next) => {
req.headers.authorization = req.headers.authorization || '';
req.token = req.headers.authorization.replace(/[^\da-z]/gi, ''); // Strip anything that isn't a digit or ASCII letter
!verify(req, users) ? res.sendStatus(CODE_UNAUTHORIZED) : next(); // skipcq: JS-0093
!verify(req, users) ? log.warn('Upload blocked', 'Unauthorized').callback(res.sendStatus, CODE_UNAUTHORIZED) : next(); // skipcq: JS-0093
});
// Upload file
//router.post('/', doUpload, processUploaded, ({ next }) => next());
router.post('/', (req, res, next) => doUpload(req, res, (err) =>
(err) ? log.error(`Multer encountered an ${!(err instanceof multer.MulterError) ? 'unknown ' : ''}error`, err).callback(next, err) : log.debug('Multer', 'File saved in temp dir').callback(next)), processUploaded, ({ next }) => next());
router.post('/', (req, res, next) => doUpload(req, res, (err) => {
log.express().Header(req, 'Content-Type');
(err) ? log.error(`Multer encountered an ${!(err instanceof multer.MulterError) ? 'unknown ' : ''}error`, err).callback(next, err) : log.debug('Multer', 'File saved in temp dir').callback(next);
}), processUploaded, ({ next }) => next());
router.use('/', (err, _req, res, next) => err.code && err.code === 'LIMIT_FILE_SIZE' ? res.status(CODE_PAYLOAD_TOO_LARGE).send(`Max upload size: ${maxUploadSize}MB`) : next(err)); // skipcq: JS-0229
router.use('/', (err, _req, res, next) => err.code && err.code === 'LIMIT_FILE_SIZE' ? log.warn('Upload blocked', 'File too large').callback(() => res.status(CODE_PAYLOAD_TOO_LARGE).send(`Max upload size: ${maxUploadSize}MB`)) : next(err)); // skipcq: JS-0229
// Process uploaded file
router.post('/', (req, res, next) => {

Loading…
Cancel
Save