@tryghost/mw-error-handler 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/mw-error-handler.js +10 -8
- package/package.json +4 -4
package/lib/mw-error-handler.js
CHANGED
|
@@ -8,12 +8,12 @@ const tpl = require('@tryghost/tpl');
|
|
|
8
8
|
const messages = {
|
|
9
9
|
pageNotFound: 'Page not found',
|
|
10
10
|
resourceNotFound: 'Resource not found',
|
|
11
|
-
|
|
11
|
+
methodNotAcceptableVersionAhead: {
|
|
12
12
|
message: 'Request not acceptable for provided Accept-Version header.',
|
|
13
13
|
context: 'Provided client version {acceptVersion} is ahead of current Ghost instance version {ghostVersion}.',
|
|
14
14
|
help: 'Upgrade your Ghost instance.'
|
|
15
15
|
},
|
|
16
|
-
|
|
16
|
+
methodNotAcceptableVersionBehind: {
|
|
17
17
|
message: 'Request not acceptable for provided Accept-Version header.',
|
|
18
18
|
context: 'Provided client version {acceptVersion} is outdated and is behind current Ghost version {ghostVersion}.',
|
|
19
19
|
help: 'Upgrade your Ghost API client.'
|
|
@@ -197,24 +197,26 @@ module.exports.resourceNotFound = (req, res, next) => {
|
|
|
197
197
|
if (versionComparison === 1) {
|
|
198
198
|
errorOptions = {
|
|
199
199
|
message: tpl(
|
|
200
|
-
messages.
|
|
200
|
+
messages.methodNotAcceptableVersionAhead.message
|
|
201
201
|
),
|
|
202
|
-
context: tpl(messages.
|
|
202
|
+
context: tpl(messages.methodNotAcceptableVersionAhead.context, {
|
|
203
203
|
acceptVersion: req.headers['accept-version'],
|
|
204
204
|
ghostVersion: `v${res.locals.safeVersion}`
|
|
205
205
|
}),
|
|
206
|
-
help: tpl(messages.
|
|
206
|
+
help: tpl(messages.methodNotAcceptableVersionAhead.help),
|
|
207
|
+
code: 'UPDATE_GHOST'
|
|
207
208
|
};
|
|
208
209
|
} else {
|
|
209
210
|
errorOptions = {
|
|
210
211
|
message: tpl(
|
|
211
|
-
messages.
|
|
212
|
+
messages.methodNotAcceptableVersionBehind.message
|
|
212
213
|
),
|
|
213
|
-
context: tpl(messages.
|
|
214
|
+
context: tpl(messages.methodNotAcceptableVersionBehind.context, {
|
|
214
215
|
acceptVersion: req.headers['accept-version'],
|
|
215
216
|
ghostVersion: `v${res.locals.safeVersion}`
|
|
216
217
|
}),
|
|
217
|
-
help: tpl(messages.
|
|
218
|
+
help: tpl(messages.methodNotAcceptableVersionBehind.help),
|
|
219
|
+
code: 'UPDATE_CLIENT'
|
|
218
220
|
};
|
|
219
221
|
}
|
|
220
222
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/mw-error-handler",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"repository": "https://github.com/TryGhost/Utils/tree/main/packages/mw-error-handler",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,17 +19,17 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"c8": "7.11.
|
|
22
|
+
"c8": "7.11.2",
|
|
23
23
|
"mocha": "9.1.3",
|
|
24
24
|
"should": "13.2.3",
|
|
25
25
|
"sinon": "12.0.1"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@tryghost/debug": "^0.1.9",
|
|
29
|
-
"@tryghost/errors": "1.2.
|
|
29
|
+
"@tryghost/errors": "1.2.11",
|
|
30
30
|
"@tryghost/tpl": "^0.1.8",
|
|
31
31
|
"lodash": "^4.17.21",
|
|
32
32
|
"semver": "^7.3.6"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "8d69959c131f54d10ccdb12bc8b45db46162a4f6"
|
|
35
35
|
}
|