checkStaticImageFormat middleware
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
const VALID_IMAGE_FORMATS = ['png', 'jpg', 'jpeg'];
|
||||
|
||||
module.exports = function checkStaticImageFormat () {
|
||||
return function checkStaticImageFormatMiddleware (req, res, next) {
|
||||
if(!VALID_IMAGE_FORMATS.includes(req.params.format.toLowerCase())) {
|
||||
return next(new Error(`Unsupported image format "${req.params.format}"`));
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user