@ -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 ) => {