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

14 lines
373 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) {
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();
};
};