2018-10-23 23:45:42 +08:00
|
|
|
'use strict';
|
|
|
|
|
2018-05-16 18:00:40 +08:00
|
|
|
const VALID_IMAGE_FORMATS = ['png', 'jpg'];
|
2018-05-11 23:41:00 +08:00
|
|
|
|
|
|
|
module.exports = function checkStaticImageFormat () {
|
|
|
|
return function checkStaticImageFormatMiddleware (req, res, next) {
|
2019-10-22 01:07:24 +08:00
|
|
|
if (!VALID_IMAGE_FORMATS.includes(req.params.format)) {
|
2018-05-11 23:41:00 +08:00
|
|
|
return next(new Error(`Unsupported image format "${req.params.format}"`));
|
|
|
|
}
|
|
|
|
|
|
|
|
next();
|
|
|
|
};
|
|
|
|
};
|