@emoyly/problem 7.0.6 → 8.0.0
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/README.md +1 -1
- package/cjs/defaults/4xx.d.ts +144 -144
- package/cjs/defaults/5xx.d.ts +54 -54
- package/cjs/defaults/aws.d.ts +8 -8
- package/cjs/defaults/cloudflare.d.ts +44 -44
- package/cjs/defaults/iis.d.ts +12 -12
- package/cjs/defaults/nginx.d.ts +24 -24
- package/cjs/defaults/others.d.ts +28 -28
- package/cjs/middleware/axios.js +1 -1
- package/cjs/middleware/base.d.ts +1 -1
- package/cjs/middleware/base.js +4 -4
- package/cjs/middleware/express.js +10 -28
- package/cjs/parsers/axios.js +9 -8
- package/cjs/parsers/jsonwebtoken.js +3 -0
- package/cjs/parsers/mikroorm.js +1 -0
- package/cjs/parsers/tsoa.js +3 -2
- package/cjs/parsers/zod.js +2 -1
- package/cjs/problem.d.ts +7 -7
- package/cjs/problem.js +41 -32
- package/cjs/tsconfig.tsbuildinfo +1 -1
- package/cjs/typings/codes.d.ts +2 -2
- package/cjs/typings/problem.d.ts +13 -2
- package/cjs/util/getProblems.d.ts +4 -4
- package/cjs/util/getProblems.js +18 -15
- package/cjs/util/index.d.ts +1 -1
- package/cjs/util/index.js +1 -1
- package/cjs/util/misc.d.ts +2 -2
- package/cjs/util/misc.js +3 -4
- package/cjs/util/validation.d.ts +5 -0
- package/cjs/util/validation.js +38 -0
- package/cjs/util/version.d.ts +1 -2
- package/cjs/util/version.js +1 -16
- package/esm/defaults/4xx.d.ts +144 -144
- package/esm/defaults/5xx.d.ts +54 -54
- package/esm/defaults/aws.d.ts +8 -8
- package/esm/defaults/cloudflare.d.ts +44 -44
- package/esm/defaults/iis.d.ts +12 -12
- package/esm/defaults/nginx.d.ts +24 -24
- package/esm/defaults/others.d.ts +28 -28
- package/esm/middleware/axios.js +1 -1
- package/esm/middleware/base.d.ts +1 -1
- package/esm/middleware/base.js +4 -4
- package/esm/middleware/express.js +11 -29
- package/esm/parsers/axios.js +9 -8
- package/esm/parsers/jsonwebtoken.js +3 -0
- package/esm/parsers/mikroorm.js +1 -0
- package/esm/parsers/tsoa.js +3 -2
- package/esm/parsers/zod.js +2 -1
- package/esm/problem.d.ts +7 -7
- package/esm/problem.js +41 -32
- package/esm/tsconfig.tsbuildinfo +1 -1
- package/esm/typings/codes.d.ts +2 -2
- package/esm/typings/problem.d.ts +13 -2
- package/esm/util/getProblems.d.ts +4 -4
- package/esm/util/getProblems.js +18 -15
- package/esm/util/index.d.ts +1 -1
- package/esm/util/index.js +1 -1
- package/esm/util/misc.d.ts +2 -2
- package/esm/util/misc.js +2 -3
- package/esm/util/validation.d.ts +5 -0
- package/esm/util/validation.js +33 -0
- package/esm/util/version.d.ts +1 -2
- package/esm/util/version.js +1 -15
- package/package.json +18 -13
- package/tsconfig.json +5 -1
- package/.editorconfig +0 -11
- package/.vscode/extensions.json +0 -7
- package/.vscode/settings.json +0 -2
- package/cjs/util/defaults.d.ts +0 -4
- package/cjs/util/defaults.js +0 -7
- package/esm/util/defaults.d.ts +0 -4
- package/esm/util/defaults.js +0 -4
- package/scripts/ensureCorrectVersion.js +0 -20
- package/src/defaults/4xx.ts +0 -149
- package/src/defaults/5xx.ts +0 -59
- package/src/defaults/aws.ts +0 -14
- package/src/defaults/cloudflare.ts +0 -50
- package/src/defaults/iis.ts +0 -19
- package/src/defaults/index.ts +0 -7
- package/src/defaults/nginx.ts +0 -34
- package/src/defaults/others.ts +0 -37
- package/src/index.ts +0 -4
- package/src/middleware/axios.ts +0 -28
- package/src/middleware/base.ts +0 -78
- package/src/middleware/express.ts +0 -71
- package/src/parsers/axios.ts +0 -60
- package/src/parsers/jsonwebtoken.ts +0 -107
- package/src/parsers/mikroorm.ts +0 -21
- package/src/parsers/tsoa.ts +0 -26
- package/src/parsers/zod.ts +0 -23
- package/src/problem.ts +0 -56
- package/src/typings/codes.ts +0 -6
- package/src/typings/index.ts +0 -4
- package/src/typings/middleware.ts +0 -14
- package/src/typings/parser.ts +0 -3
- package/src/typings/problem.ts +0 -27
- package/src/util/defaults.ts +0 -4
- package/src/util/getProblems.ts +0 -56
- package/src/util/index.ts +0 -4
- package/src/util/misc.ts +0 -21
- package/src/util/problemArray.ts +0 -21
- package/src/util/version.ts +0 -16
package/esm/util/getProblems.js
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import { Problem } from '../problem.js';
|
|
2
2
|
import { isProblemArray } from './problemArray.js';
|
|
3
|
-
import {
|
|
4
|
-
const strings = ['title', 'type', 'instance', 'detail', '__problemVersion'];
|
|
3
|
+
import { validateBasicInput } from './validation.js';
|
|
5
4
|
export function isJsonProblem(input) {
|
|
6
|
-
|
|
7
|
-
return false;
|
|
8
|
-
if (typeof input !== 'object')
|
|
9
|
-
return false;
|
|
10
|
-
if (!strings.every(val => val in input && typeof input[val] === 'string'))
|
|
11
|
-
return false;
|
|
12
|
-
if (!isCompatibleVersion(('__problemVersion' in input && typeof input['__problemVersion'] === 'string') ? input['__problemVersion'] : ''))
|
|
13
|
-
return false;
|
|
14
|
-
if (!('status' in input) || typeof input.status !== 'number')
|
|
15
|
-
return false;
|
|
16
|
-
return true;
|
|
5
|
+
return validateBasicInput(input) === true;
|
|
17
6
|
}
|
|
18
|
-
export function createFromJson({ title, type, instance, detail, status, data }) {
|
|
7
|
+
export function createFromJson({ title, type, instance, detail, status, data: _data, ...extras }) {
|
|
8
|
+
let data;
|
|
9
|
+
const extraKeys = Object.keys(extras);
|
|
10
|
+
if /* No extras, just use data */ (extraKeys.length < 1) {
|
|
11
|
+
data = _data;
|
|
12
|
+
}
|
|
13
|
+
else if /* Extras but no data, just use extras */ ((_data === undefined || _data === null)) {
|
|
14
|
+
data = extras;
|
|
15
|
+
}
|
|
16
|
+
else if /* Data is not object we can merge with, and we do have extras */ (typeof _data !== 'object' || Array.isArray(_data) || Object.keys(_data).some(val => extraKeys.includes(val))) {
|
|
17
|
+
data = { original: _data, extras };
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
data = { ...extras, ..._data };
|
|
21
|
+
}
|
|
19
22
|
return new Problem({ title, type, instance, detail, status, data });
|
|
20
23
|
}
|
|
21
24
|
/**
|
|
22
|
-
* Get an array of Problems from
|
|
25
|
+
* Get an array of Problems from any given input.
|
|
23
26
|
* Handles existing Problems, arrays of Problems, JSON Problems, JSON Problem arrays and optionally attempts to parse any input with the given parsers.
|
|
24
27
|
* Only returns an array of Problems if it can successfully parse the input.
|
|
25
28
|
*/
|
package/esm/util/index.d.ts
CHANGED
package/esm/util/index.js
CHANGED
package/esm/util/misc.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function
|
|
1
|
+
import { CodeOpts } from '../typings/index.js';
|
|
2
|
+
export declare function getCodeDefaults(statusCode: number | string): CodeOpts | undefined;
|
package/esm/util/misc.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as allCodes from '../defaults/index.js';
|
|
2
|
-
export function
|
|
2
|
+
export function getCodeDefaults(statusCode) {
|
|
3
3
|
for (const key in allCodes) {
|
|
4
|
-
// This ensures all codes are written correctly as well, so that's a bonus
|
|
5
4
|
const codeObject = allCodes[key];
|
|
6
5
|
if (typeof statusCode === 'string') {
|
|
7
6
|
const conv = Number(statusCode);
|
|
@@ -10,7 +9,7 @@ export function getHttpError(statusCode) {
|
|
|
10
9
|
}
|
|
11
10
|
const code = codeObject[statusCode];
|
|
12
11
|
if (!code)
|
|
13
|
-
|
|
12
|
+
continue;
|
|
14
13
|
return code;
|
|
15
14
|
}
|
|
16
15
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export class ProblemValidationError extends Error {
|
|
2
|
+
errors;
|
|
3
|
+
constructor(errors) {
|
|
4
|
+
super(`Problem input is invalid:\n${errors.join('\n')}`);
|
|
5
|
+
this.errors = errors;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
const requiredStrings = ['title', 'type'];
|
|
9
|
+
const optionalStrings = ['detail', '__problemVersion', 'instance', 'stack', 'source'];
|
|
10
|
+
export function validateBasicInput(input) {
|
|
11
|
+
const errors = [];
|
|
12
|
+
if (input === null) {
|
|
13
|
+
errors.push('Input is null');
|
|
14
|
+
return new ProblemValidationError(errors);
|
|
15
|
+
}
|
|
16
|
+
if (typeof input !== 'object') {
|
|
17
|
+
errors.push('Input is not an object');
|
|
18
|
+
return new ProblemValidationError(errors);
|
|
19
|
+
}
|
|
20
|
+
const missingRequired = requiredStrings.filter(val => typeof input[val] !== 'string');
|
|
21
|
+
for (const miss of missingRequired) {
|
|
22
|
+
errors.push(`"${miss}" is missing or not a string`);
|
|
23
|
+
}
|
|
24
|
+
const wrongOptional = optionalStrings.filter((val) => val in input && input[val] !== undefined && input[val] !== null && typeof input[val] !== 'string');
|
|
25
|
+
for (const wrong of wrongOptional) {
|
|
26
|
+
errors.push(`"${wrong}" is set, and is not a string`);
|
|
27
|
+
}
|
|
28
|
+
if (!('status' in input) || typeof input.status !== 'number')
|
|
29
|
+
errors.push('Status is not a number');
|
|
30
|
+
if (errors.length > 0)
|
|
31
|
+
return new ProblemValidationError(errors);
|
|
32
|
+
return true;
|
|
33
|
+
}
|
package/esm/util/version.d.ts
CHANGED
package/esm/util/version.js
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
export const version = '
|
|
1
|
+
export const version = '8.0.0';
|
|
2
2
|
export const major = Number(version.split('.')[0]);
|
|
3
|
-
export function isCompatibleVersion(inputVersion) {
|
|
4
|
-
// TODO: Remove this
|
|
5
|
-
if (inputVersion === 'lua-dev')
|
|
6
|
-
return true;
|
|
7
|
-
const parts = inputVersion.split('.');
|
|
8
|
-
const inputMajor = Number(parts[0]);
|
|
9
|
-
if (parts.length !== 3)
|
|
10
|
-
return false;
|
|
11
|
-
if (isNaN(inputMajor))
|
|
12
|
-
return false;
|
|
13
|
-
if (inputMajor !== major)
|
|
14
|
-
return false;
|
|
15
|
-
return true;
|
|
16
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emoyly/problem",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "A simple error library based around the RFC-7807 standard with optional support for different parsers and middleware.",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"repository": "https://github.com/emoyly/problem",
|
|
@@ -8,27 +8,32 @@
|
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"scripts": {
|
|
11
|
-
"build": "yarn dualBuild",
|
|
12
|
-
"lint": "eslint src &&
|
|
13
|
-
"publish": "yarn npm publish --access public --tolerate-republish"
|
|
11
|
+
"build": "yarn dualBuild && tsc -p test/tsconfig.json",
|
|
12
|
+
"lint": "eslint src && eslint test",
|
|
13
|
+
"publish": "yarn npm publish --access public --tolerate-republish",
|
|
14
|
+
"test": "node --import @swc-node/register/esm-register --test ./test/**/*.test.ts"
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
16
17
|
"@emoyly/devutils": "^1.0.5",
|
|
17
18
|
"@emoyly/eslint-config": "^1.1.2",
|
|
18
19
|
"@emoyly/utils": "^1.0.4",
|
|
19
|
-
"@mikro-orm/core": "^6.4.
|
|
20
|
-
"@stylistic/eslint-plugin-js": "^2.
|
|
21
|
-
"@stylistic/eslint-plugin-ts": "^2.
|
|
20
|
+
"@mikro-orm/core": "^6.4.1",
|
|
21
|
+
"@stylistic/eslint-plugin-js": "^2.12.1",
|
|
22
|
+
"@stylistic/eslint-plugin-ts": "^2.12.1",
|
|
23
|
+
"@swc-node/register": "^1.10.9",
|
|
24
|
+
"@swc/core": "^1.10.1",
|
|
22
25
|
"@types/express": "^5.0.0",
|
|
23
26
|
"@types/jsonwebtoken": "^9.0.7",
|
|
24
|
-
"@types/node": "^22.10.
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
+
"@types/node": "^22.10.2",
|
|
28
|
+
"@types/semver": "^7",
|
|
29
|
+
"axios": "^1.7.9",
|
|
30
|
+
"eslint": "^9.17.0",
|
|
27
31
|
"jsonwebtoken": "^9.0.2",
|
|
28
|
-
"
|
|
32
|
+
"semver": "^7.6.3",
|
|
33
|
+
"tsoa": "^6.6.0",
|
|
29
34
|
"typescript": "^5.7.2",
|
|
30
|
-
"typescript-eslint": "^8.
|
|
31
|
-
"zod": "^3.
|
|
35
|
+
"typescript-eslint": "^8.18.1",
|
|
36
|
+
"zod": "^3.24.1"
|
|
32
37
|
},
|
|
33
38
|
"peerDependencies": {
|
|
34
39
|
"@mikro-orm/core": "*",
|
package/tsconfig.json
CHANGED
package/.editorconfig
DELETED
package/.vscode/extensions.json
DELETED
package/.vscode/settings.json
DELETED
package/cjs/util/defaults.d.ts
DELETED
package/cjs/util/defaults.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultInstance = exports.defaultDetail = exports.defaultTitle = exports.defaultType = void 0;
|
|
4
|
-
exports.defaultType = '/errors/default/unknown';
|
|
5
|
-
exports.defaultTitle = 'Unknown error';
|
|
6
|
-
exports.defaultDetail = 'No extended details are available';
|
|
7
|
-
exports.defaultInstance = '/unknown';
|
package/esm/util/defaults.d.ts
DELETED
package/esm/util/defaults.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
import * as fs from 'node:fs'
|
|
3
|
-
import * as path from 'node:path'
|
|
4
|
-
import { fileURLToPath } from 'node:url'
|
|
5
|
-
|
|
6
|
-
const dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
7
|
-
|
|
8
|
-
const { version } = JSON.parse(fs.readFileSync(path.join(dirname, '..', 'package.json'), 'utf-8'))
|
|
9
|
-
const versionTs = fs.readFileSync(path.join(dirname, '../src/util/version.ts'), 'utf-8')
|
|
10
|
-
|
|
11
|
-
const match = versionTs.match(/(?<=export const version = ')(\d+\.\d+\.\d+)(?=')/)
|
|
12
|
-
if (!match?.[0]){
|
|
13
|
-
throw new Error('Could not find version in version.ts')
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (match[0] !== version){
|
|
17
|
-
throw new Error(`Version in version.ts (${match[0]}) does not match package.json (${version})`)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
//console.log(`Version in version.ts matches package.json: ${version}`)
|
package/src/defaults/4xx.ts
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
// Source: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
|
|
2
|
-
|
|
3
|
-
export const statusCodes = {
|
|
4
|
-
400: {
|
|
5
|
-
status: 400,
|
|
6
|
-
title: 'Bad Request',
|
|
7
|
-
type: '/errors/defaults/4xx/badrequest',
|
|
8
|
-
},
|
|
9
|
-
401: {
|
|
10
|
-
status: 401,
|
|
11
|
-
title: 'Unauthorized',
|
|
12
|
-
type: '/errors/defaults/4xx/unauthorized',
|
|
13
|
-
},
|
|
14
|
-
402: {
|
|
15
|
-
status: 402,
|
|
16
|
-
title: 'Payment Required',
|
|
17
|
-
type: '/errors/defaults/4xx/paymentrequired',
|
|
18
|
-
},
|
|
19
|
-
403: {
|
|
20
|
-
status: 403,
|
|
21
|
-
title: 'Forbidden',
|
|
22
|
-
type: '/errors/defaults/4xx/forbidden',
|
|
23
|
-
},
|
|
24
|
-
404: {
|
|
25
|
-
status: 404,
|
|
26
|
-
title: 'Not Found',
|
|
27
|
-
type: '/errors/defaults/4xx/notfound',
|
|
28
|
-
},
|
|
29
|
-
406: {
|
|
30
|
-
status: 406,
|
|
31
|
-
title: 'Not Acceptable',
|
|
32
|
-
type: 'errors/defaults/4xx/notacceptable'
|
|
33
|
-
},
|
|
34
|
-
405: {
|
|
35
|
-
status: 405,
|
|
36
|
-
title: 'Method Not Allowed',
|
|
37
|
-
type: 'errors/defaults/4xx/methodnotallowed'
|
|
38
|
-
},
|
|
39
|
-
407: {
|
|
40
|
-
status: 407,
|
|
41
|
-
title: 'Proxy Authentication Required (RFC 7235)',
|
|
42
|
-
type: 'errors/defaults/4xx/proxyauthenticationrequired'
|
|
43
|
-
},
|
|
44
|
-
408: {
|
|
45
|
-
status: 408,
|
|
46
|
-
title: 'Request Timeout',
|
|
47
|
-
type: 'errors/defaults/4xx/requesttimeout'
|
|
48
|
-
},
|
|
49
|
-
409: {
|
|
50
|
-
status: 409,
|
|
51
|
-
title: 'Conflict',
|
|
52
|
-
type: 'errors/defaults/4xx/conflict'
|
|
53
|
-
},
|
|
54
|
-
410: {
|
|
55
|
-
status: 410,
|
|
56
|
-
title: 'Gone',
|
|
57
|
-
type: 'errors/defaults/4xx/gone'
|
|
58
|
-
},
|
|
59
|
-
411: {
|
|
60
|
-
status: 411,
|
|
61
|
-
title: 'Length Required',
|
|
62
|
-
type: 'errors/defaults/4xx/lengthrequired'
|
|
63
|
-
},
|
|
64
|
-
412: {
|
|
65
|
-
status: 412,
|
|
66
|
-
title: 'Precondition Failed (RFC 7232)',
|
|
67
|
-
type: 'errors/defaults/4xx/preconditionfailed'
|
|
68
|
-
},
|
|
69
|
-
413: {
|
|
70
|
-
status: 413,
|
|
71
|
-
title: 'Payload Too Large (RFC 7231)',
|
|
72
|
-
type: 'errors/defaults/4xx/payloadtoolarge'
|
|
73
|
-
},
|
|
74
|
-
414: {
|
|
75
|
-
status: 414,
|
|
76
|
-
title: 'URI Too Long (RFC 7231)',
|
|
77
|
-
type: 'errors/defaults/4xx/uritoolong'
|
|
78
|
-
},
|
|
79
|
-
415: {
|
|
80
|
-
status: 415,
|
|
81
|
-
title: 'Unsupported Media Type (RFC 7231)',
|
|
82
|
-
type: 'errors/defaults/4xx/unsupportedmediatype'
|
|
83
|
-
},
|
|
84
|
-
416: {
|
|
85
|
-
status: 416,
|
|
86
|
-
title: 'Range Not Satisfiable (RFC 7233)',
|
|
87
|
-
type: 'errors/defaults/4xx/rangenotsatisfiable'
|
|
88
|
-
},
|
|
89
|
-
417: {
|
|
90
|
-
status: 417,
|
|
91
|
-
title: 'Expectation Failed',
|
|
92
|
-
type: 'errors/defaults/4xx/expectationfailed'
|
|
93
|
-
},
|
|
94
|
-
418: {
|
|
95
|
-
status: 418,
|
|
96
|
-
title: 'I\'m a teapot (RFC 2324, RFC 7168)',
|
|
97
|
-
type: 'errors/defaults/4xx/i\'mateapot'
|
|
98
|
-
},
|
|
99
|
-
421: {
|
|
100
|
-
status: 421,
|
|
101
|
-
title: 'Misdirected Request (RFC 7540)',
|
|
102
|
-
type: 'errors/defaults/4xx/misdirectedrequest'
|
|
103
|
-
},
|
|
104
|
-
422: {
|
|
105
|
-
status: 422,
|
|
106
|
-
title: 'Unprocessable Entity (WebDAV; RFC 4918)',
|
|
107
|
-
type: 'errors/defaults/4xx/unprocessableentity'
|
|
108
|
-
},
|
|
109
|
-
423: {
|
|
110
|
-
status: 423,
|
|
111
|
-
title: 'Locked (WebDAV; RFC 4918)',
|
|
112
|
-
type: 'errors/defaults/4xx/locked'
|
|
113
|
-
},
|
|
114
|
-
424: {
|
|
115
|
-
status: 424,
|
|
116
|
-
title: 'Failed Dependency (WebDAV; RFC 4918)',
|
|
117
|
-
type: 'errors/defaults/4xx/faileddependency'
|
|
118
|
-
},
|
|
119
|
-
425: {
|
|
120
|
-
status: 425,
|
|
121
|
-
title: 'Too Early (RFC 8470)',
|
|
122
|
-
type: 'errors/defaults/4xx/tooearly'
|
|
123
|
-
},
|
|
124
|
-
426: {
|
|
125
|
-
status: 426,
|
|
126
|
-
title: 'Upgrade Required',
|
|
127
|
-
type: 'errors/defaults/4xx/upgraderequired'
|
|
128
|
-
},
|
|
129
|
-
428: {
|
|
130
|
-
status: 428,
|
|
131
|
-
title: 'Precondition Required (RFC 6585)',
|
|
132
|
-
type: 'errors/defaults/4xx/preconditionrequired'
|
|
133
|
-
},
|
|
134
|
-
429: {
|
|
135
|
-
status: 429,
|
|
136
|
-
title: 'Too Many Requests (RFC 6585)',
|
|
137
|
-
type: 'errors/defaults/4xx/toomanyrequests'
|
|
138
|
-
},
|
|
139
|
-
431: {
|
|
140
|
-
status: 431,
|
|
141
|
-
title: 'Request Header Fields Too Large (RFC 6585)',
|
|
142
|
-
type: 'errors/defaults/4xx/requestheaderfieldstoolarge'
|
|
143
|
-
},
|
|
144
|
-
451: {
|
|
145
|
-
status: 451,
|
|
146
|
-
title: 'Unavailable For Legal Reasons (RFC 7725)',
|
|
147
|
-
type: 'errors/defaults/4xx/unavailableforlegalreasons'
|
|
148
|
-
}
|
|
149
|
-
}
|
package/src/defaults/5xx.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// Source: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
|
|
2
|
-
|
|
3
|
-
export const statusCodes = {
|
|
4
|
-
500: {
|
|
5
|
-
status: 500,
|
|
6
|
-
title: 'Internal Server Error',
|
|
7
|
-
type: 'errors/defaults/5xx/internalservererror'
|
|
8
|
-
},
|
|
9
|
-
501: {
|
|
10
|
-
status: 501,
|
|
11
|
-
title: 'Not Implemented',
|
|
12
|
-
type: 'errors/defaults/5xx/notimplemented'
|
|
13
|
-
},
|
|
14
|
-
502: {
|
|
15
|
-
status: 502,
|
|
16
|
-
title: 'Bad Gateway',
|
|
17
|
-
type: 'errors/defaults/5xx/badgateway'
|
|
18
|
-
},
|
|
19
|
-
503: {
|
|
20
|
-
status: 503,
|
|
21
|
-
title: 'Service Unavailable',
|
|
22
|
-
type: 'errors/defaults/5xx/serviceunavailable'
|
|
23
|
-
},
|
|
24
|
-
504: {
|
|
25
|
-
status: 504,
|
|
26
|
-
title: 'Gateway Timeout',
|
|
27
|
-
type: 'errors/defaults/5xx/gatewaytimeout'
|
|
28
|
-
},
|
|
29
|
-
505: {
|
|
30
|
-
status: 505,
|
|
31
|
-
title: 'HTTP Version Not Supported',
|
|
32
|
-
type: 'errors/defaults/5xx/httpversionnotsupported'
|
|
33
|
-
},
|
|
34
|
-
506: {
|
|
35
|
-
status: 506,
|
|
36
|
-
title: 'Variant Also Negotiates (RFC 2295)',
|
|
37
|
-
type: 'errors/defaults/5xx/variantalsonegotiates'
|
|
38
|
-
},
|
|
39
|
-
507: {
|
|
40
|
-
status: 507,
|
|
41
|
-
title: 'Insufficient Storage (WebDAV; RFC 4918)',
|
|
42
|
-
type: 'errors/defaults/5xx/insufficientstorage'
|
|
43
|
-
},
|
|
44
|
-
508: {
|
|
45
|
-
status: 508,
|
|
46
|
-
title: 'Loop Detected (WebDAV; RFC 5842)',
|
|
47
|
-
type: 'errors/defaults/5xx/loopdetected'
|
|
48
|
-
},
|
|
49
|
-
511: {
|
|
50
|
-
status: 511,
|
|
51
|
-
title: 'Network Authentication Required (RFC 6585)',
|
|
52
|
-
type: 'errors/defaults/5xx/networkauthenticationrequired'
|
|
53
|
-
},
|
|
54
|
-
510: {
|
|
55
|
-
status: 510,
|
|
56
|
-
title: 'Not Extended (RFC 2774)',
|
|
57
|
-
type: 'errors/defaults/5xx/notextended'
|
|
58
|
-
}
|
|
59
|
-
}
|
package/src/defaults/aws.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// Source: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-troubleshooting.html
|
|
2
|
-
|
|
3
|
-
export const statusCodes = {
|
|
4
|
-
460: {
|
|
5
|
-
status: 460,
|
|
6
|
-
title: 'Client closed connection before idle timeout period elapsed',
|
|
7
|
-
type: '/errors/defaults/aws/clientclosedbeforetimeout',
|
|
8
|
-
},
|
|
9
|
-
463: {
|
|
10
|
-
status: 463,
|
|
11
|
-
title: 'X-Forwarded-For contains more than 30 ips',
|
|
12
|
-
type: '/errors/defaults/aws/toomanyips'
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// Source: https://support.cloudflare.com/hc/en-us/articles/115003011431
|
|
2
|
-
|
|
3
|
-
export const statusCodes = {
|
|
4
|
-
520: {
|
|
5
|
-
status: 520,
|
|
6
|
-
title: 'Web Server returned an unknown error',
|
|
7
|
-
type: '/errors/defaults/cloudflare/unknownerror',
|
|
8
|
-
},
|
|
9
|
-
521: {
|
|
10
|
-
status: 521,
|
|
11
|
-
title: 'Web server is down',
|
|
12
|
-
type: '/errors/defaults/cloudflare/webserverdown',
|
|
13
|
-
},
|
|
14
|
-
522: {
|
|
15
|
-
status: 522,
|
|
16
|
-
title: 'Connection timed out',
|
|
17
|
-
type: '/errors/defaults/cloudflare/connectiontimeout',
|
|
18
|
-
},
|
|
19
|
-
523: {
|
|
20
|
-
status: 523,
|
|
21
|
-
title: 'Origin is unreachable',
|
|
22
|
-
type: '/errors/defaults/cloudflare/originunreachable'
|
|
23
|
-
},
|
|
24
|
-
524: {
|
|
25
|
-
status: 524,
|
|
26
|
-
title: 'A timeout occurred',
|
|
27
|
-
type: '/errors/defaults/cloudflare/timeout'
|
|
28
|
-
},
|
|
29
|
-
525: {
|
|
30
|
-
status: 525,
|
|
31
|
-
title: 'SSL handshake failed',
|
|
32
|
-
type: '/errors/defaults/cloudflare/sslhandshakefail'
|
|
33
|
-
},
|
|
34
|
-
526: {
|
|
35
|
-
status: 526,
|
|
36
|
-
title: 'Invalid SSL certificate',
|
|
37
|
-
type: '/errors/defaults/cloudflare/invalidssl'
|
|
38
|
-
},
|
|
39
|
-
// A 527 error indicates an interrupted connection between Cloudflare and your origin's Railgun server (rg-listener)
|
|
40
|
-
527: {
|
|
41
|
-
status: 527,
|
|
42
|
-
title: 'Railgun Listener to origin error',
|
|
43
|
-
type: '/errors/defaults/cloudflare/railgunoriginerr'
|
|
44
|
-
},
|
|
45
|
-
530: {
|
|
46
|
-
status: 530,
|
|
47
|
-
title: 'Cloudflare returned 1xxx error',
|
|
48
|
-
type: '/errors/defaults/cloudflare/1xxx'
|
|
49
|
-
}
|
|
50
|
-
}
|
package/src/defaults/iis.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Source: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
|
|
2
|
-
|
|
3
|
-
export const statusCodes = {
|
|
4
|
-
440: {
|
|
5
|
-
status: 440,
|
|
6
|
-
title: 'Login Time-out',
|
|
7
|
-
type: '/errors/defaults/iis/logintimeout',
|
|
8
|
-
},
|
|
9
|
-
449: {
|
|
10
|
-
status: 449,
|
|
11
|
-
title: 'Retry with required information',
|
|
12
|
-
type: '/errors/defaults/iis/retrywith'
|
|
13
|
-
},
|
|
14
|
-
451: {
|
|
15
|
-
status: 451,
|
|
16
|
-
title: 'Redirect',
|
|
17
|
-
type: '/errors/defaults/iis/redirect'
|
|
18
|
-
}
|
|
19
|
-
}
|
package/src/defaults/index.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { statusCodes as codes4xx } from '../defaults/4xx.js'
|
|
2
|
-
export { statusCodes as codes5xx } from '../defaults/5xx.js'
|
|
3
|
-
export { statusCodes as codesAws } from '../defaults/aws.js'
|
|
4
|
-
export { statusCodes as codesCloudflare } from '../defaults/cloudflare.js'
|
|
5
|
-
export { statusCodes as codesIis } from '../defaults/iis.js'
|
|
6
|
-
export { statusCodes as codesNginx } from '../defaults/nginx.js'
|
|
7
|
-
export { otherErrors } from '../defaults/others.js'
|
package/src/defaults/nginx.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// Source: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
|
|
2
|
-
|
|
3
|
-
export const statusCodes = {
|
|
4
|
-
444: {
|
|
5
|
-
status: 494,
|
|
6
|
-
title: 'No Response',
|
|
7
|
-
type: '/errors/defaults/nginx/noresponse',
|
|
8
|
-
},
|
|
9
|
-
494: {
|
|
10
|
-
status: 494,
|
|
11
|
-
title: 'Request header too large',
|
|
12
|
-
type: '/errors/defaults/nginx/headertoolarge',
|
|
13
|
-
},
|
|
14
|
-
495: {
|
|
15
|
-
status: 495,
|
|
16
|
-
title: 'SSL Certificate Error',
|
|
17
|
-
type: '/errors/defaults/nginx/sslcerterr'
|
|
18
|
-
},
|
|
19
|
-
496: {
|
|
20
|
-
status: 496,
|
|
21
|
-
title: 'SSL Certificate Required',
|
|
22
|
-
type: '/errors/defaults/nginx/sslcertrequired'
|
|
23
|
-
},
|
|
24
|
-
497: {
|
|
25
|
-
status: 497,
|
|
26
|
-
title: 'HTTP Request Sent to HTTPS Port',
|
|
27
|
-
type: '/errors/defaults/nginx/httpreqtohttpsport'
|
|
28
|
-
},
|
|
29
|
-
499: {
|
|
30
|
-
status: 499,
|
|
31
|
-
title: 'Client Closed Request',
|
|
32
|
-
type: '/errors/defaults/nginx/clientclosedreq'
|
|
33
|
-
}
|
|
34
|
-
}
|
package/src/defaults/others.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export const otherErrors = {
|
|
2
|
-
'unknown': {
|
|
3
|
-
status: 500,
|
|
4
|
-
title: 'Unknown error',
|
|
5
|
-
type: '/errors/defaults/others/unknown',
|
|
6
|
-
},
|
|
7
|
-
'corsError': {
|
|
8
|
-
status: 401,
|
|
9
|
-
title: 'Request not allowed by CORS policy',
|
|
10
|
-
type: '/errors/defaults/others/corsdenied',
|
|
11
|
-
},
|
|
12
|
-
'problemParseError': {
|
|
13
|
-
status: 1000,
|
|
14
|
-
title: 'Could not parse problem details',
|
|
15
|
-
type: '/errors/defaults/others/problemparseerror',
|
|
16
|
-
},
|
|
17
|
-
'problemJsonError': {
|
|
18
|
-
status: 1000,
|
|
19
|
-
title: 'Could not parse problem JSON',
|
|
20
|
-
type: '/errors/defaults/others/problemjsonerror',
|
|
21
|
-
},
|
|
22
|
-
'notAnError': {
|
|
23
|
-
status: 1000,
|
|
24
|
-
title: 'Not an error',
|
|
25
|
-
type: '/errors/defaults/others/notanerror',
|
|
26
|
-
},
|
|
27
|
-
'networkError': {
|
|
28
|
-
status: 1000,
|
|
29
|
-
title: 'Network error',
|
|
30
|
-
type: '/errors/defaults/others/networkerror'
|
|
31
|
-
},
|
|
32
|
-
'inputValidationError': {
|
|
33
|
-
status: 400,
|
|
34
|
-
title: 'Input failed validation',
|
|
35
|
-
type: '/errors/defaults/others/validationerror'
|
|
36
|
-
}
|
|
37
|
-
}
|