Windshaft-cartodb/lib/api/middlewares/check-static-image-format.js

14 lines
374 B
JavaScript
Raw Normal View History

'use strict';
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();
};
};