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

21 lines
579 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(
i18n.t(
'errors.middleware.api.versionMismatch',
{requestVersion: requestVersion, currentVersion: currentVersion}
)
));
}
next();
}
module.exports = checkVersionMatch;