@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.
Files changed (102) hide show
  1. package/README.md +1 -1
  2. package/cjs/defaults/4xx.d.ts +144 -144
  3. package/cjs/defaults/5xx.d.ts +54 -54
  4. package/cjs/defaults/aws.d.ts +8 -8
  5. package/cjs/defaults/cloudflare.d.ts +44 -44
  6. package/cjs/defaults/iis.d.ts +12 -12
  7. package/cjs/defaults/nginx.d.ts +24 -24
  8. package/cjs/defaults/others.d.ts +28 -28
  9. package/cjs/middleware/axios.js +1 -1
  10. package/cjs/middleware/base.d.ts +1 -1
  11. package/cjs/middleware/base.js +4 -4
  12. package/cjs/middleware/express.js +10 -28
  13. package/cjs/parsers/axios.js +9 -8
  14. package/cjs/parsers/jsonwebtoken.js +3 -0
  15. package/cjs/parsers/mikroorm.js +1 -0
  16. package/cjs/parsers/tsoa.js +3 -2
  17. package/cjs/parsers/zod.js +2 -1
  18. package/cjs/problem.d.ts +7 -7
  19. package/cjs/problem.js +41 -32
  20. package/cjs/tsconfig.tsbuildinfo +1 -1
  21. package/cjs/typings/codes.d.ts +2 -2
  22. package/cjs/typings/problem.d.ts +13 -2
  23. package/cjs/util/getProblems.d.ts +4 -4
  24. package/cjs/util/getProblems.js +18 -15
  25. package/cjs/util/index.d.ts +1 -1
  26. package/cjs/util/index.js +1 -1
  27. package/cjs/util/misc.d.ts +2 -2
  28. package/cjs/util/misc.js +3 -4
  29. package/cjs/util/validation.d.ts +5 -0
  30. package/cjs/util/validation.js +38 -0
  31. package/cjs/util/version.d.ts +1 -2
  32. package/cjs/util/version.js +1 -16
  33. package/esm/defaults/4xx.d.ts +144 -144
  34. package/esm/defaults/5xx.d.ts +54 -54
  35. package/esm/defaults/aws.d.ts +8 -8
  36. package/esm/defaults/cloudflare.d.ts +44 -44
  37. package/esm/defaults/iis.d.ts +12 -12
  38. package/esm/defaults/nginx.d.ts +24 -24
  39. package/esm/defaults/others.d.ts +28 -28
  40. package/esm/middleware/axios.js +1 -1
  41. package/esm/middleware/base.d.ts +1 -1
  42. package/esm/middleware/base.js +4 -4
  43. package/esm/middleware/express.js +11 -29
  44. package/esm/parsers/axios.js +9 -8
  45. package/esm/parsers/jsonwebtoken.js +3 -0
  46. package/esm/parsers/mikroorm.js +1 -0
  47. package/esm/parsers/tsoa.js +3 -2
  48. package/esm/parsers/zod.js +2 -1
  49. package/esm/problem.d.ts +7 -7
  50. package/esm/problem.js +41 -32
  51. package/esm/tsconfig.tsbuildinfo +1 -1
  52. package/esm/typings/codes.d.ts +2 -2
  53. package/esm/typings/problem.d.ts +13 -2
  54. package/esm/util/getProblems.d.ts +4 -4
  55. package/esm/util/getProblems.js +18 -15
  56. package/esm/util/index.d.ts +1 -1
  57. package/esm/util/index.js +1 -1
  58. package/esm/util/misc.d.ts +2 -2
  59. package/esm/util/misc.js +2 -3
  60. package/esm/util/validation.d.ts +5 -0
  61. package/esm/util/validation.js +33 -0
  62. package/esm/util/version.d.ts +1 -2
  63. package/esm/util/version.js +1 -15
  64. package/package.json +18 -13
  65. package/tsconfig.json +5 -1
  66. package/.editorconfig +0 -11
  67. package/.vscode/extensions.json +0 -7
  68. package/.vscode/settings.json +0 -2
  69. package/cjs/util/defaults.d.ts +0 -4
  70. package/cjs/util/defaults.js +0 -7
  71. package/esm/util/defaults.d.ts +0 -4
  72. package/esm/util/defaults.js +0 -4
  73. package/scripts/ensureCorrectVersion.js +0 -20
  74. package/src/defaults/4xx.ts +0 -149
  75. package/src/defaults/5xx.ts +0 -59
  76. package/src/defaults/aws.ts +0 -14
  77. package/src/defaults/cloudflare.ts +0 -50
  78. package/src/defaults/iis.ts +0 -19
  79. package/src/defaults/index.ts +0 -7
  80. package/src/defaults/nginx.ts +0 -34
  81. package/src/defaults/others.ts +0 -37
  82. package/src/index.ts +0 -4
  83. package/src/middleware/axios.ts +0 -28
  84. package/src/middleware/base.ts +0 -78
  85. package/src/middleware/express.ts +0 -71
  86. package/src/parsers/axios.ts +0 -60
  87. package/src/parsers/jsonwebtoken.ts +0 -107
  88. package/src/parsers/mikroorm.ts +0 -21
  89. package/src/parsers/tsoa.ts +0 -26
  90. package/src/parsers/zod.ts +0 -23
  91. package/src/problem.ts +0 -56
  92. package/src/typings/codes.ts +0 -6
  93. package/src/typings/index.ts +0 -4
  94. package/src/typings/middleware.ts +0 -14
  95. package/src/typings/parser.ts +0 -3
  96. package/src/typings/problem.ts +0 -27
  97. package/src/util/defaults.ts +0 -4
  98. package/src/util/getProblems.ts +0 -56
  99. package/src/util/index.ts +0 -4
  100. package/src/util/misc.ts +0 -21
  101. package/src/util/problemArray.ts +0 -21
  102. package/src/util/version.ts +0 -16
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Problem is an error handling library, based around the [RFC-7807 standard](https://tools.ietf.org/html/rfc7807), with support for additional parsers and middleware (Explained below).
5
5
  The library may not follow the standard completely in some cases. An example of which is that it currently only supports the JSON variant of problem details.
6
- There is also other features added, making it much more of an HTTP error handling framework, than just an implementation of the standard.
6
+ There are also additional features, making it more of an HTTP error handling framework, than just an implementation of the standard.
7
7
 
8
8
  # Terms
9
9
 
@@ -1,147 +1,147 @@
1
1
  export declare const statusCodes: {
2
- 400: {
3
- status: number;
4
- title: string;
5
- type: string;
6
- };
7
- 401: {
8
- status: number;
9
- title: string;
10
- type: string;
11
- };
12
- 402: {
13
- status: number;
14
- title: string;
15
- type: string;
16
- };
17
- 403: {
18
- status: number;
19
- title: string;
20
- type: string;
21
- };
22
- 404: {
23
- status: number;
24
- title: string;
25
- type: string;
26
- };
27
- 406: {
28
- status: number;
29
- title: string;
30
- type: string;
31
- };
32
- 405: {
33
- status: number;
34
- title: string;
35
- type: string;
36
- };
37
- 407: {
38
- status: number;
39
- title: string;
40
- type: string;
41
- };
42
- 408: {
43
- status: number;
44
- title: string;
45
- type: string;
46
- };
47
- 409: {
48
- status: number;
49
- title: string;
50
- type: string;
51
- };
52
- 410: {
53
- status: number;
54
- title: string;
55
- type: string;
56
- };
57
- 411: {
58
- status: number;
59
- title: string;
60
- type: string;
61
- };
62
- 412: {
63
- status: number;
64
- title: string;
65
- type: string;
66
- };
67
- 413: {
68
- status: number;
69
- title: string;
70
- type: string;
71
- };
72
- 414: {
73
- status: number;
74
- title: string;
75
- type: string;
76
- };
77
- 415: {
78
- status: number;
79
- title: string;
80
- type: string;
81
- };
82
- 416: {
83
- status: number;
84
- title: string;
85
- type: string;
86
- };
87
- 417: {
88
- status: number;
89
- title: string;
90
- type: string;
91
- };
92
- 418: {
93
- status: number;
94
- title: string;
95
- type: string;
96
- };
97
- 421: {
98
- status: number;
99
- title: string;
100
- type: string;
101
- };
102
- 422: {
103
- status: number;
104
- title: string;
105
- type: string;
106
- };
107
- 423: {
108
- status: number;
109
- title: string;
110
- type: string;
111
- };
112
- 424: {
113
- status: number;
114
- title: string;
115
- type: string;
116
- };
117
- 425: {
118
- status: number;
119
- title: string;
120
- type: string;
121
- };
122
- 426: {
123
- status: number;
124
- title: string;
125
- type: string;
126
- };
127
- 428: {
128
- status: number;
129
- title: string;
130
- type: string;
131
- };
132
- 429: {
133
- status: number;
134
- title: string;
135
- type: string;
136
- };
137
- 431: {
138
- status: number;
139
- title: string;
140
- type: string;
141
- };
142
- 451: {
143
- status: number;
144
- title: string;
145
- type: string;
2
+ readonly 400: {
3
+ readonly status: 400;
4
+ readonly title: "Bad Request";
5
+ readonly type: "/errors/defaults/4xx/badrequest";
6
+ };
7
+ readonly 401: {
8
+ readonly status: 401;
9
+ readonly title: "Unauthorized";
10
+ readonly type: "/errors/defaults/4xx/unauthorized";
11
+ };
12
+ readonly 402: {
13
+ readonly status: 402;
14
+ readonly title: "Payment Required";
15
+ readonly type: "/errors/defaults/4xx/paymentrequired";
16
+ };
17
+ readonly 403: {
18
+ readonly status: 403;
19
+ readonly title: "Forbidden";
20
+ readonly type: "/errors/defaults/4xx/forbidden";
21
+ };
22
+ readonly 404: {
23
+ readonly status: 404;
24
+ readonly title: "Not Found";
25
+ readonly type: "/errors/defaults/4xx/notfound";
26
+ };
27
+ readonly 406: {
28
+ readonly status: 406;
29
+ readonly title: "Not Acceptable";
30
+ readonly type: "errors/defaults/4xx/notacceptable";
31
+ };
32
+ readonly 405: {
33
+ readonly status: 405;
34
+ readonly title: "Method Not Allowed";
35
+ readonly type: "errors/defaults/4xx/methodnotallowed";
36
+ };
37
+ readonly 407: {
38
+ readonly status: 407;
39
+ readonly title: "Proxy Authentication Required (RFC 7235)";
40
+ readonly type: "errors/defaults/4xx/proxyauthenticationrequired";
41
+ };
42
+ readonly 408: {
43
+ readonly status: 408;
44
+ readonly title: "Request Timeout";
45
+ readonly type: "errors/defaults/4xx/requesttimeout";
46
+ };
47
+ readonly 409: {
48
+ readonly status: 409;
49
+ readonly title: "Conflict";
50
+ readonly type: "errors/defaults/4xx/conflict";
51
+ };
52
+ readonly 410: {
53
+ readonly status: 410;
54
+ readonly title: "Gone";
55
+ readonly type: "errors/defaults/4xx/gone";
56
+ };
57
+ readonly 411: {
58
+ readonly status: 411;
59
+ readonly title: "Length Required";
60
+ readonly type: "errors/defaults/4xx/lengthrequired";
61
+ };
62
+ readonly 412: {
63
+ readonly status: 412;
64
+ readonly title: "Precondition Failed (RFC 7232)";
65
+ readonly type: "errors/defaults/4xx/preconditionfailed";
66
+ };
67
+ readonly 413: {
68
+ readonly status: 413;
69
+ readonly title: "Payload Too Large (RFC 7231)";
70
+ readonly type: "errors/defaults/4xx/payloadtoolarge";
71
+ };
72
+ readonly 414: {
73
+ readonly status: 414;
74
+ readonly title: "URI Too Long (RFC 7231)";
75
+ readonly type: "errors/defaults/4xx/uritoolong";
76
+ };
77
+ readonly 415: {
78
+ readonly status: 415;
79
+ readonly title: "Unsupported Media Type (RFC 7231)";
80
+ readonly type: "errors/defaults/4xx/unsupportedmediatype";
81
+ };
82
+ readonly 416: {
83
+ readonly status: 416;
84
+ readonly title: "Range Not Satisfiable (RFC 7233)";
85
+ readonly type: "errors/defaults/4xx/rangenotsatisfiable";
86
+ };
87
+ readonly 417: {
88
+ readonly status: 417;
89
+ readonly title: "Expectation Failed";
90
+ readonly type: "errors/defaults/4xx/expectationfailed";
91
+ };
92
+ readonly 418: {
93
+ readonly status: 418;
94
+ readonly title: "I'm a teapot (RFC 2324, RFC 7168)";
95
+ readonly type: "errors/defaults/4xx/i'mateapot";
96
+ };
97
+ readonly 421: {
98
+ readonly status: 421;
99
+ readonly title: "Misdirected Request (RFC 7540)";
100
+ readonly type: "errors/defaults/4xx/misdirectedrequest";
101
+ };
102
+ readonly 422: {
103
+ readonly status: 422;
104
+ readonly title: "Unprocessable Entity (WebDAV; RFC 4918)";
105
+ readonly type: "errors/defaults/4xx/unprocessableentity";
106
+ };
107
+ readonly 423: {
108
+ readonly status: 423;
109
+ readonly title: "Locked (WebDAV; RFC 4918)";
110
+ readonly type: "errors/defaults/4xx/locked";
111
+ };
112
+ readonly 424: {
113
+ readonly status: 424;
114
+ readonly title: "Failed Dependency (WebDAV; RFC 4918)";
115
+ readonly type: "errors/defaults/4xx/faileddependency";
116
+ };
117
+ readonly 425: {
118
+ readonly status: 425;
119
+ readonly title: "Too Early (RFC 8470)";
120
+ readonly type: "errors/defaults/4xx/tooearly";
121
+ };
122
+ readonly 426: {
123
+ readonly status: 426;
124
+ readonly title: "Upgrade Required";
125
+ readonly type: "errors/defaults/4xx/upgraderequired";
126
+ };
127
+ readonly 428: {
128
+ readonly status: 428;
129
+ readonly title: "Precondition Required (RFC 6585)";
130
+ readonly type: "errors/defaults/4xx/preconditionrequired";
131
+ };
132
+ readonly 429: {
133
+ readonly status: 429;
134
+ readonly title: "Too Many Requests (RFC 6585)";
135
+ readonly type: "errors/defaults/4xx/toomanyrequests";
136
+ };
137
+ readonly 431: {
138
+ readonly status: 431;
139
+ readonly title: "Request Header Fields Too Large (RFC 6585)";
140
+ readonly type: "errors/defaults/4xx/requestheaderfieldstoolarge";
141
+ };
142
+ readonly 451: {
143
+ readonly status: 451;
144
+ readonly title: "Unavailable For Legal Reasons (RFC 7725)";
145
+ readonly type: "errors/defaults/4xx/unavailableforlegalreasons";
146
146
  };
147
147
  };
@@ -1,57 +1,57 @@
1
1
  export declare const statusCodes: {
2
- 500: {
3
- status: number;
4
- title: string;
5
- type: string;
6
- };
7
- 501: {
8
- status: number;
9
- title: string;
10
- type: string;
11
- };
12
- 502: {
13
- status: number;
14
- title: string;
15
- type: string;
16
- };
17
- 503: {
18
- status: number;
19
- title: string;
20
- type: string;
21
- };
22
- 504: {
23
- status: number;
24
- title: string;
25
- type: string;
26
- };
27
- 505: {
28
- status: number;
29
- title: string;
30
- type: string;
31
- };
32
- 506: {
33
- status: number;
34
- title: string;
35
- type: string;
36
- };
37
- 507: {
38
- status: number;
39
- title: string;
40
- type: string;
41
- };
42
- 508: {
43
- status: number;
44
- title: string;
45
- type: string;
46
- };
47
- 511: {
48
- status: number;
49
- title: string;
50
- type: string;
51
- };
52
- 510: {
53
- status: number;
54
- title: string;
55
- type: string;
2
+ readonly 500: {
3
+ readonly status: 500;
4
+ readonly title: "Internal Server Error";
5
+ readonly type: "errors/defaults/5xx/internalservererror";
6
+ };
7
+ readonly 501: {
8
+ readonly status: 501;
9
+ readonly title: "Not Implemented";
10
+ readonly type: "errors/defaults/5xx/notimplemented";
11
+ };
12
+ readonly 502: {
13
+ readonly status: 502;
14
+ readonly title: "Bad Gateway";
15
+ readonly type: "errors/defaults/5xx/badgateway";
16
+ };
17
+ readonly 503: {
18
+ readonly status: 503;
19
+ readonly title: "Service Unavailable";
20
+ readonly type: "errors/defaults/5xx/serviceunavailable";
21
+ };
22
+ readonly 504: {
23
+ readonly status: 504;
24
+ readonly title: "Gateway Timeout";
25
+ readonly type: "errors/defaults/5xx/gatewaytimeout";
26
+ };
27
+ readonly 505: {
28
+ readonly status: 505;
29
+ readonly title: "HTTP Version Not Supported";
30
+ readonly type: "errors/defaults/5xx/httpversionnotsupported";
31
+ };
32
+ readonly 506: {
33
+ readonly status: 506;
34
+ readonly title: "Variant Also Negotiates (RFC 2295)";
35
+ readonly type: "errors/defaults/5xx/variantalsonegotiates";
36
+ };
37
+ readonly 507: {
38
+ readonly status: 507;
39
+ readonly title: "Insufficient Storage (WebDAV; RFC 4918)";
40
+ readonly type: "errors/defaults/5xx/insufficientstorage";
41
+ };
42
+ readonly 508: {
43
+ readonly status: 508;
44
+ readonly title: "Loop Detected (WebDAV; RFC 5842)";
45
+ readonly type: "errors/defaults/5xx/loopdetected";
46
+ };
47
+ readonly 511: {
48
+ readonly status: 511;
49
+ readonly title: "Network Authentication Required (RFC 6585)";
50
+ readonly type: "errors/defaults/5xx/networkauthenticationrequired";
51
+ };
52
+ readonly 510: {
53
+ readonly status: 510;
54
+ readonly title: "Not Extended (RFC 2774)";
55
+ readonly type: "errors/defaults/5xx/notextended";
56
56
  };
57
57
  };
@@ -1,12 +1,12 @@
1
1
  export declare const statusCodes: {
2
- 460: {
3
- status: number;
4
- title: string;
5
- type: string;
2
+ readonly 460: {
3
+ readonly status: 460;
4
+ readonly title: "Client closed connection before idle timeout period elapsed";
5
+ readonly type: "/errors/defaults/aws/clientclosedbeforetimeout";
6
6
  };
7
- 463: {
8
- status: number;
9
- title: string;
10
- type: string;
7
+ readonly 463: {
8
+ readonly status: 463;
9
+ readonly title: "X-Forwarded-For contains more than 30 ips";
10
+ readonly type: "/errors/defaults/aws/toomanyips";
11
11
  };
12
12
  };
@@ -1,47 +1,47 @@
1
1
  export declare const statusCodes: {
2
- 520: {
3
- status: number;
4
- title: string;
5
- type: string;
6
- };
7
- 521: {
8
- status: number;
9
- title: string;
10
- type: string;
11
- };
12
- 522: {
13
- status: number;
14
- title: string;
15
- type: string;
16
- };
17
- 523: {
18
- status: number;
19
- title: string;
20
- type: string;
21
- };
22
- 524: {
23
- status: number;
24
- title: string;
25
- type: string;
26
- };
27
- 525: {
28
- status: number;
29
- title: string;
30
- type: string;
31
- };
32
- 526: {
33
- status: number;
34
- title: string;
35
- type: string;
36
- };
37
- 527: {
38
- status: number;
39
- title: string;
40
- type: string;
41
- };
42
- 530: {
43
- status: number;
44
- title: string;
45
- type: string;
2
+ readonly 520: {
3
+ readonly status: 520;
4
+ readonly title: "Web Server returned an unknown error";
5
+ readonly type: "/errors/defaults/cloudflare/unknownerror";
6
+ };
7
+ readonly 521: {
8
+ readonly status: 521;
9
+ readonly title: "Web server is down";
10
+ readonly type: "/errors/defaults/cloudflare/webserverdown";
11
+ };
12
+ readonly 522: {
13
+ readonly status: 522;
14
+ readonly title: "Connection timed out";
15
+ readonly type: "/errors/defaults/cloudflare/connectiontimeout";
16
+ };
17
+ readonly 523: {
18
+ readonly status: 523;
19
+ readonly title: "Origin is unreachable";
20
+ readonly type: "/errors/defaults/cloudflare/originunreachable";
21
+ };
22
+ readonly 524: {
23
+ readonly status: 524;
24
+ readonly title: "A timeout occurred";
25
+ readonly type: "/errors/defaults/cloudflare/timeout";
26
+ };
27
+ readonly 525: {
28
+ readonly status: 525;
29
+ readonly title: "SSL handshake failed";
30
+ readonly type: "/errors/defaults/cloudflare/sslhandshakefail";
31
+ };
32
+ readonly 526: {
33
+ readonly status: 526;
34
+ readonly title: "Invalid SSL certificate";
35
+ readonly type: "/errors/defaults/cloudflare/invalidssl";
36
+ };
37
+ readonly 527: {
38
+ readonly status: 527;
39
+ readonly title: "Railgun Listener to origin error";
40
+ readonly type: "/errors/defaults/cloudflare/railgunoriginerr";
41
+ };
42
+ readonly 530: {
43
+ readonly status: 530;
44
+ readonly title: "Cloudflare returned 1xxx error";
45
+ readonly type: "/errors/defaults/cloudflare/1xxx";
46
46
  };
47
47
  };
@@ -1,17 +1,17 @@
1
1
  export declare const statusCodes: {
2
- 440: {
3
- status: number;
4
- title: string;
5
- type: string;
2
+ readonly 440: {
3
+ readonly status: 440;
4
+ readonly title: "Login Time-out";
5
+ readonly type: "/errors/defaults/iis/logintimeout";
6
6
  };
7
- 449: {
8
- status: number;
9
- title: string;
10
- type: string;
7
+ readonly 449: {
8
+ readonly status: 449;
9
+ readonly title: "Retry with required information";
10
+ readonly type: "/errors/defaults/iis/retrywith";
11
11
  };
12
- 451: {
13
- status: number;
14
- title: string;
15
- type: string;
12
+ readonly 451: {
13
+ readonly status: 451;
14
+ readonly title: "Redirect";
15
+ readonly type: "/errors/defaults/iis/redirect";
16
16
  };
17
17
  };
@@ -1,32 +1,32 @@
1
1
  export declare const statusCodes: {
2
- 444: {
3
- status: number;
4
- title: string;
5
- type: string;
2
+ readonly 444: {
3
+ readonly status: 494;
4
+ readonly title: "No Response";
5
+ readonly type: "/errors/defaults/nginx/noresponse";
6
6
  };
7
- 494: {
8
- status: number;
9
- title: string;
10
- type: string;
7
+ readonly 494: {
8
+ readonly status: 494;
9
+ readonly title: "Request header too large";
10
+ readonly type: "/errors/defaults/nginx/headertoolarge";
11
11
  };
12
- 495: {
13
- status: number;
14
- title: string;
15
- type: string;
12
+ readonly 495: {
13
+ readonly status: 495;
14
+ readonly title: "SSL Certificate Error";
15
+ readonly type: "/errors/defaults/nginx/sslcerterr";
16
16
  };
17
- 496: {
18
- status: number;
19
- title: string;
20
- type: string;
17
+ readonly 496: {
18
+ readonly status: 496;
19
+ readonly title: "SSL Certificate Required";
20
+ readonly type: "/errors/defaults/nginx/sslcertrequired";
21
21
  };
22
- 497: {
23
- status: number;
24
- title: string;
25
- type: string;
22
+ readonly 497: {
23
+ readonly status: 497;
24
+ readonly title: "HTTP Request Sent to HTTPS Port";
25
+ readonly type: "/errors/defaults/nginx/httpreqtohttpsport";
26
26
  };
27
- 499: {
28
- status: number;
29
- title: string;
30
- type: string;
27
+ readonly 499: {
28
+ readonly status: 499;
29
+ readonly title: "Client Closed Request";
30
+ readonly type: "/errors/defaults/nginx/clientclosedreq";
31
31
  };
32
32
  };