Renamed variables to match their content

refs https://github.com/TryGhost/Toolbox/issues/280

- The naming of variables should've been vice-versa. Should make the code less confusing now
This commit is contained in:
Naz 2022-04-13 13:29:57 +08:00
parent 6804e5d2c6
commit ebc8881d65

View File

@ -8,12 +8,12 @@ const tpl = require('@tryghost/tpl');
const messages = {
pageNotFound: 'Page not found',
resourceNotFound: 'Resource not found',
methodNotAcceptableVersionBehind: {
methodNotAcceptableVersionAhead: {
message: 'Request not acceptable for provided Accept-Version header.',
context: 'Provided client version {acceptVersion} is ahead of current Ghost instance version {ghostVersion}.',
help: 'Upgrade your Ghost instance.'
},
methodNotAcceptableVersionAhead: {
methodNotAcceptableVersionBehind: {
message: 'Request not acceptable for provided Accept-Version header.',
context: 'Provided client version {acceptVersion} is outdated and is behind current Ghost version {ghostVersion}.',
help: 'Upgrade your Ghost API client.'
@ -195,17 +195,6 @@ module.exports.resourceNotFound = (req, res, next) => {
let errorOptions;
if (versionComparison === 1) {
errorOptions = {
message: tpl(
messages.methodNotAcceptableVersionBehind.message
),
context: tpl(messages.methodNotAcceptableVersionBehind.context, {
acceptVersion: req.headers['accept-version'],
ghostVersion: `v${res.locals.safeVersion}`
}),
help: tpl(messages.methodNotAcceptableVersionBehind.help)
};
} else {
errorOptions = {
message: tpl(
messages.methodNotAcceptableVersionAhead.message
@ -216,6 +205,17 @@ module.exports.resourceNotFound = (req, res, next) => {
}),
help: tpl(messages.methodNotAcceptableVersionAhead.help)
};
} else {
errorOptions = {
message: tpl(
messages.methodNotAcceptableVersionBehind.message
),
context: tpl(messages.methodNotAcceptableVersionBehind.context, {
acceptVersion: req.headers['accept-version'],
ghostVersion: `v${res.locals.safeVersion}`
}),
help: tpl(messages.methodNotAcceptableVersionBehind.help)
};
}
next(new errors.RequestNotAcceptableError(errorOptions));