Ghost/core/server/middleware/api/version-match.js

18 lines
544 B
JavaScript
Raw Normal View History

var errors = require('../../errors'),
i18n = require('../../i18n');
function checkVersionMatch(req, res, next) {
var requestVersion = req.get('X-Ghost-Version'),
currentVersion = res.locals.safeVersion;
if (requestVersion && requestVersion !== currentVersion) {
return next(new errors.VersionMismatchError({
message: i18n.t('errors.middleware.api.versionMismatch', {requestVersion: requestVersion, currentVersion: currentVersion})
}));
}
next();
}
module.exports = checkVersionMatch;