@emoyly/problem 5.0.7 → 6.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 (175) hide show
  1. package/.editorconfig +11 -0
  2. package/.vscode/extensions.json +7 -0
  3. package/.vscode/settings.json +2 -0
  4. package/.yarn/versions/524dd037.yml +0 -0
  5. package/.yarn/versions/b57d536b.yml +0 -0
  6. package/.yarn/versions/d984e272.yml +0 -0
  7. package/cjs/defaults/index.d.ts +7 -0
  8. package/cjs/defaults/index.js +17 -0
  9. package/cjs/index.d.ts +5 -0
  10. package/cjs/index.js +24 -0
  11. package/{middleware → cjs/middleware}/axios.d.ts +2 -2
  12. package/cjs/middleware/axios.js +24 -0
  13. package/{middleware → cjs/middleware}/base.d.ts +3 -3
  14. package/cjs/middleware/base.js +52 -0
  15. package/{middleware → cjs/middleware}/express.d.ts +2 -2
  16. package/cjs/middleware/express.js +65 -0
  17. package/cjs/package.json +3 -0
  18. package/cjs/parsers/axios.d.ts +3 -0
  19. package/cjs/parsers/axios.js +55 -0
  20. package/cjs/parsers/jsonwebtoken.d.ts +3 -0
  21. package/{parsers → cjs/parsers}/jsonwebtoken.js +4 -4
  22. package/cjs/parsers/mikroorm.d.ts +3 -0
  23. package/{parsers → cjs/parsers}/mikroorm.js +7 -3
  24. package/cjs/parsers/tsoa.d.ts +3 -0
  25. package/{parsers → cjs/parsers}/tsoa.js +10 -4
  26. package/{problem.d.ts → cjs/problem.d.ts} +1 -1
  27. package/{problem.js → cjs/problem.js} +24 -23
  28. package/cjs/tsconfig.tsbuildinfo +1 -0
  29. package/{typings → cjs/typings}/codes.d.ts +1 -1
  30. package/{typings → cjs/typings}/events.d.ts +1 -1
  31. package/cjs/typings/index.d.ts +5 -0
  32. package/{typings → cjs/typings}/index.js +5 -5
  33. package/{typings → cjs/typings}/middleware.d.ts +1 -1
  34. package/{typings → cjs/typings}/parser.d.ts +1 -1
  35. package/{util → cjs/util}/events.d.ts +2 -2
  36. package/cjs/util/events.js +27 -0
  37. package/{util → cjs/util}/getProblems.d.ts +2 -2
  38. package/{util → cjs/util}/getProblems.js +10 -11
  39. package/{util → cjs/util}/isProblemArray.d.ts +1 -1
  40. package/{util → cjs/util}/isProblemArray.js +3 -4
  41. package/{util → cjs/util}/misc.d.ts +1 -1
  42. package/cjs/util/misc.js +19 -0
  43. package/{util → cjs/util}/version.d.ts +1 -1
  44. package/{util → cjs/util}/version.js +3 -3
  45. package/eslint.config.mjs +5 -0
  46. package/esm/defaults/4xx.d.ts +147 -0
  47. package/esm/defaults/4xx.js +148 -0
  48. package/esm/defaults/5xx.d.ts +57 -0
  49. package/esm/defaults/5xx.js +58 -0
  50. package/esm/defaults/aws.d.ts +12 -0
  51. package/esm/defaults/aws.js +13 -0
  52. package/esm/defaults/cloudflare.d.ts +47 -0
  53. package/esm/defaults/cloudflare.js +49 -0
  54. package/esm/defaults/iis.d.ts +17 -0
  55. package/esm/defaults/iis.js +18 -0
  56. package/esm/defaults/index.d.ts +7 -0
  57. package/esm/defaults/index.js +7 -0
  58. package/esm/defaults/nginx.d.ts +32 -0
  59. package/esm/defaults/nginx.js +33 -0
  60. package/esm/defaults/others.d.ts +37 -0
  61. package/esm/defaults/others.js +37 -0
  62. package/esm/index.d.ts +5 -0
  63. package/esm/index.js +5 -0
  64. package/esm/middleware/axios.d.ts +13 -0
  65. package/esm/middleware/axios.js +20 -0
  66. package/esm/middleware/base.d.ts +24 -0
  67. package/esm/middleware/base.js +48 -0
  68. package/esm/middleware/express.d.ts +19 -0
  69. package/esm/middleware/express.js +61 -0
  70. package/esm/package.json +3 -0
  71. package/esm/parsers/axios.d.ts +3 -0
  72. package/esm/parsers/axios.js +53 -0
  73. package/esm/parsers/jsonwebtoken.d.ts +3 -0
  74. package/esm/parsers/jsonwebtoken.js +94 -0
  75. package/esm/parsers/mikroorm.d.ts +3 -0
  76. package/esm/parsers/mikroorm.js +17 -0
  77. package/esm/parsers/tsoa.d.ts +3 -0
  78. package/esm/parsers/tsoa.js +21 -0
  79. package/esm/problem.d.ts +14 -0
  80. package/esm/problem.js +56 -0
  81. package/esm/tsconfig.tsbuildinfo +1 -0
  82. package/esm/typings/codes.d.ts +5 -0
  83. package/esm/typings/codes.js +1 -0
  84. package/esm/typings/events.d.ts +2 -0
  85. package/esm/typings/events.js +1 -0
  86. package/esm/typings/index.d.ts +5 -0
  87. package/esm/typings/index.js +5 -0
  88. package/esm/typings/middleware.d.ts +9 -0
  89. package/esm/typings/middleware.js +1 -0
  90. package/esm/typings/parser.d.ts +2 -0
  91. package/esm/typings/parser.js +1 -0
  92. package/esm/typings/problem.d.ts +24 -0
  93. package/esm/typings/problem.js +11 -0
  94. package/esm/util/defaults.d.ts +4 -0
  95. package/esm/util/defaults.js +4 -0
  96. package/esm/util/events.d.ts +16 -0
  97. package/esm/util/events.js +25 -0
  98. package/esm/util/getProblems.d.ts +5 -0
  99. package/esm/util/getProblems.js +40 -0
  100. package/esm/util/isProblemArray.d.ts +2 -0
  101. package/esm/util/isProblemArray.js +6 -0
  102. package/esm/util/misc.d.ts +2 -0
  103. package/esm/util/misc.js +16 -0
  104. package/esm/util/version.d.ts +3 -0
  105. package/esm/util/version.js +16 -0
  106. package/package.json +51 -28
  107. package/scripts/ensureCorrectVersion.js +8 -4
  108. package/src/defaults/4xx.ts +149 -0
  109. package/src/defaults/5xx.ts +59 -0
  110. package/src/defaults/aws.ts +14 -0
  111. package/src/defaults/cloudflare.ts +50 -0
  112. package/src/defaults/iis.ts +19 -0
  113. package/src/defaults/index.ts +7 -0
  114. package/src/defaults/nginx.ts +34 -0
  115. package/src/defaults/others.ts +37 -0
  116. package/src/index.ts +5 -0
  117. package/src/middleware/axios.ts +29 -0
  118. package/src/middleware/base.ts +64 -0
  119. package/src/middleware/express.ts +72 -0
  120. package/src/parsers/axios.ts +61 -0
  121. package/src/parsers/jsonwebtoken.ts +104 -0
  122. package/src/parsers/mikroorm.ts +21 -0
  123. package/src/parsers/tsoa.ts +25 -0
  124. package/src/problem.ts +56 -0
  125. package/src/typings/codes.ts +6 -0
  126. package/src/typings/events.ts +3 -0
  127. package/src/typings/index.ts +5 -0
  128. package/src/typings/middleware.ts +11 -0
  129. package/src/typings/parser.ts +3 -0
  130. package/src/typings/problem.ts +27 -0
  131. package/src/util/defaults.ts +4 -0
  132. package/src/util/events.ts +34 -0
  133. package/src/util/getProblems.ts +43 -0
  134. package/src/util/isProblemArray.ts +6 -0
  135. package/src/util/misc.ts +20 -0
  136. package/src/util/version.ts +16 -0
  137. package/tsconfig.json +15 -0
  138. package/defaults/index.d.ts +0 -7
  139. package/defaults/index.js +0 -17
  140. package/index.d.ts +0 -5
  141. package/index.js +0 -39
  142. package/middleware/axios.js +0 -36
  143. package/middleware/base.js +0 -56
  144. package/middleware/express.js +0 -60
  145. package/parsers/axios.d.ts +0 -3
  146. package/parsers/axios.js +0 -41
  147. package/parsers/jsonwebtoken.d.ts +0 -3
  148. package/parsers/mikroorm.d.ts +0 -3
  149. package/parsers/tsoa.d.ts +0 -3
  150. package/tsconfig.tsbuildinfo +0 -1
  151. package/typings/index.d.ts +0 -5
  152. package/util/events.js +0 -29
  153. package/util/misc.js +0 -43
  154. /package/{defaults → cjs/defaults}/4xx.d.ts +0 -0
  155. /package/{defaults → cjs/defaults}/4xx.js +0 -0
  156. /package/{defaults → cjs/defaults}/5xx.d.ts +0 -0
  157. /package/{defaults → cjs/defaults}/5xx.js +0 -0
  158. /package/{defaults → cjs/defaults}/aws.d.ts +0 -0
  159. /package/{defaults → cjs/defaults}/aws.js +0 -0
  160. /package/{defaults → cjs/defaults}/cloudflare.d.ts +0 -0
  161. /package/{defaults → cjs/defaults}/cloudflare.js +0 -0
  162. /package/{defaults → cjs/defaults}/iis.d.ts +0 -0
  163. /package/{defaults → cjs/defaults}/iis.js +0 -0
  164. /package/{defaults → cjs/defaults}/nginx.d.ts +0 -0
  165. /package/{defaults → cjs/defaults}/nginx.js +0 -0
  166. /package/{defaults → cjs/defaults}/others.d.ts +0 -0
  167. /package/{defaults → cjs/defaults}/others.js +0 -0
  168. /package/{typings → cjs/typings}/codes.js +0 -0
  169. /package/{typings → cjs/typings}/events.js +0 -0
  170. /package/{typings → cjs/typings}/middleware.js +0 -0
  171. /package/{typings → cjs/typings}/parser.js +0 -0
  172. /package/{typings → cjs/typings}/problem.d.ts +0 -0
  173. /package/{typings → cjs/typings}/problem.js +0 -0
  174. /package/{util → cjs/util}/defaults.d.ts +0 -0
  175. /package/{util → cjs/util}/defaults.js +0 -0
@@ -0,0 +1,148 @@
1
+ // Source: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
2
+ export const statusCodes = {
3
+ 400: {
4
+ status: 400,
5
+ title: 'Bad Request',
6
+ type: '/errors/defaults/4xx/badrequest',
7
+ },
8
+ 401: {
9
+ status: 401,
10
+ title: 'Unauthorized',
11
+ type: '/errors/defaults/4xx/unauthorized',
12
+ },
13
+ 402: {
14
+ status: 402,
15
+ title: 'Payment Required',
16
+ type: '/errors/defaults/4xx/paymentrequired',
17
+ },
18
+ 403: {
19
+ status: 403,
20
+ title: 'Forbidden',
21
+ type: '/errors/defaults/4xx/forbidden',
22
+ },
23
+ 404: {
24
+ status: 404,
25
+ title: 'Not Found',
26
+ type: '/errors/defaults/4xx/notfound',
27
+ },
28
+ 406: {
29
+ status: 406,
30
+ title: 'Not Acceptable',
31
+ type: 'errors/defaults/4xx/notacceptable'
32
+ },
33
+ 405: {
34
+ status: 405,
35
+ title: 'Method Not Allowed',
36
+ type: 'errors/defaults/4xx/methodnotallowed'
37
+ },
38
+ 407: {
39
+ status: 407,
40
+ title: 'Proxy Authentication Required (RFC 7235)',
41
+ type: 'errors/defaults/4xx/proxyauthenticationrequired'
42
+ },
43
+ 408: {
44
+ status: 408,
45
+ title: 'Request Timeout',
46
+ type: 'errors/defaults/4xx/requesttimeout'
47
+ },
48
+ 409: {
49
+ status: 409,
50
+ title: 'Conflict',
51
+ type: 'errors/defaults/4xx/conflict'
52
+ },
53
+ 410: {
54
+ status: 410,
55
+ title: 'Gone',
56
+ type: 'errors/defaults/4xx/gone'
57
+ },
58
+ 411: {
59
+ status: 411,
60
+ title: 'Length Required',
61
+ type: 'errors/defaults/4xx/lengthrequired'
62
+ },
63
+ 412: {
64
+ status: 412,
65
+ title: 'Precondition Failed (RFC 7232)',
66
+ type: 'errors/defaults/4xx/preconditionfailed'
67
+ },
68
+ 413: {
69
+ status: 413,
70
+ title: 'Payload Too Large (RFC 7231)',
71
+ type: 'errors/defaults/4xx/payloadtoolarge'
72
+ },
73
+ 414: {
74
+ status: 414,
75
+ title: 'URI Too Long (RFC 7231)',
76
+ type: 'errors/defaults/4xx/uritoolong'
77
+ },
78
+ 415: {
79
+ status: 415,
80
+ title: 'Unsupported Media Type (RFC 7231)',
81
+ type: 'errors/defaults/4xx/unsupportedmediatype'
82
+ },
83
+ 416: {
84
+ status: 416,
85
+ title: 'Range Not Satisfiable (RFC 7233)',
86
+ type: 'errors/defaults/4xx/rangenotsatisfiable'
87
+ },
88
+ 417: {
89
+ status: 417,
90
+ title: 'Expectation Failed',
91
+ type: 'errors/defaults/4xx/expectationfailed'
92
+ },
93
+ 418: {
94
+ status: 418,
95
+ title: 'I\'m a teapot (RFC 2324, RFC 7168)',
96
+ type: 'errors/defaults/4xx/i\'mateapot'
97
+ },
98
+ 421: {
99
+ status: 421,
100
+ title: 'Misdirected Request (RFC 7540)',
101
+ type: 'errors/defaults/4xx/misdirectedrequest'
102
+ },
103
+ 422: {
104
+ status: 422,
105
+ title: 'Unprocessable Entity (WebDAV; RFC 4918)',
106
+ type: 'errors/defaults/4xx/unprocessableentity'
107
+ },
108
+ 423: {
109
+ status: 423,
110
+ title: 'Locked (WebDAV; RFC 4918)',
111
+ type: 'errors/defaults/4xx/locked'
112
+ },
113
+ 424: {
114
+ status: 424,
115
+ title: 'Failed Dependency (WebDAV; RFC 4918)',
116
+ type: 'errors/defaults/4xx/faileddependency'
117
+ },
118
+ 425: {
119
+ status: 425,
120
+ title: 'Too Early (RFC 8470)',
121
+ type: 'errors/defaults/4xx/tooearly'
122
+ },
123
+ 426: {
124
+ status: 426,
125
+ title: 'Upgrade Required',
126
+ type: 'errors/defaults/4xx/upgraderequired'
127
+ },
128
+ 428: {
129
+ status: 428,
130
+ title: 'Precondition Required (RFC 6585)',
131
+ type: 'errors/defaults/4xx/preconditionrequired'
132
+ },
133
+ 429: {
134
+ status: 429,
135
+ title: 'Too Many Requests (RFC 6585)',
136
+ type: 'errors/defaults/4xx/toomanyrequests'
137
+ },
138
+ 431: {
139
+ status: 431,
140
+ title: 'Request Header Fields Too Large (RFC 6585)',
141
+ type: 'errors/defaults/4xx/requestheaderfieldstoolarge'
142
+ },
143
+ 451: {
144
+ status: 451,
145
+ title: 'Unavailable For Legal Reasons (RFC 7725)',
146
+ type: 'errors/defaults/4xx/unavailableforlegalreasons'
147
+ }
148
+ };
@@ -0,0 +1,57 @@
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;
56
+ };
57
+ };
@@ -0,0 +1,58 @@
1
+ // Source: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
2
+ export const statusCodes = {
3
+ 500: {
4
+ status: 500,
5
+ title: 'Internal Server Error',
6
+ type: 'errors/defaults/5xx/internalservererror'
7
+ },
8
+ 501: {
9
+ status: 501,
10
+ title: 'Not Implemented',
11
+ type: 'errors/defaults/5xx/notimplemented'
12
+ },
13
+ 502: {
14
+ status: 502,
15
+ title: 'Bad Gateway',
16
+ type: 'errors/defaults/5xx/badgateway'
17
+ },
18
+ 503: {
19
+ status: 503,
20
+ title: 'Service Unavailable',
21
+ type: 'errors/defaults/5xx/serviceunavailable'
22
+ },
23
+ 504: {
24
+ status: 504,
25
+ title: 'Gateway Timeout',
26
+ type: 'errors/defaults/5xx/gatewaytimeout'
27
+ },
28
+ 505: {
29
+ status: 505,
30
+ title: 'HTTP Version Not Supported',
31
+ type: 'errors/defaults/5xx/httpversionnotsupported'
32
+ },
33
+ 506: {
34
+ status: 506,
35
+ title: 'Variant Also Negotiates (RFC 2295)',
36
+ type: 'errors/defaults/5xx/variantalsonegotiates'
37
+ },
38
+ 507: {
39
+ status: 507,
40
+ title: 'Insufficient Storage (WebDAV; RFC 4918)',
41
+ type: 'errors/defaults/5xx/insufficientstorage'
42
+ },
43
+ 508: {
44
+ status: 508,
45
+ title: 'Loop Detected (WebDAV; RFC 5842)',
46
+ type: 'errors/defaults/5xx/loopdetected'
47
+ },
48
+ 511: {
49
+ status: 511,
50
+ title: 'Network Authentication Required (RFC 6585)',
51
+ type: 'errors/defaults/5xx/networkauthenticationrequired'
52
+ },
53
+ 510: {
54
+ status: 510,
55
+ title: 'Not Extended (RFC 2774)',
56
+ type: 'errors/defaults/5xx/notextended'
57
+ }
58
+ };
@@ -0,0 +1,12 @@
1
+ export declare const statusCodes: {
2
+ 460: {
3
+ status: number;
4
+ title: string;
5
+ type: string;
6
+ };
7
+ 463: {
8
+ status: number;
9
+ title: string;
10
+ type: string;
11
+ };
12
+ };
@@ -0,0 +1,13 @@
1
+ // Source: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-troubleshooting.html
2
+ export const statusCodes = {
3
+ 460: {
4
+ status: 460,
5
+ title: 'Client closed connection before idle timeout period elapsed',
6
+ type: '/errors/defaults/aws/clientclosedbeforetimeout',
7
+ },
8
+ 463: {
9
+ status: 463,
10
+ title: 'X-Forwarded-For contains more than 30 ips',
11
+ type: '/errors/defaults/aws/toomanyips'
12
+ }
13
+ };
@@ -0,0 +1,47 @@
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;
46
+ };
47
+ };
@@ -0,0 +1,49 @@
1
+ // Source: https://support.cloudflare.com/hc/en-us/articles/115003011431
2
+ export const statusCodes = {
3
+ 520: {
4
+ status: 520,
5
+ title: 'Web Server returned an unknown error',
6
+ type: '/errors/defaults/cloudflare/unknownerror',
7
+ },
8
+ 521: {
9
+ status: 521,
10
+ title: 'Web server is down',
11
+ type: '/errors/defaults/cloudflare/webserverdown',
12
+ },
13
+ 522: {
14
+ status: 522,
15
+ title: 'Connection timed out',
16
+ type: '/errors/defaults/cloudflare/connectiontimeout',
17
+ },
18
+ 523: {
19
+ status: 523,
20
+ title: 'Origin is unreachable',
21
+ type: '/errors/defaults/cloudflare/originunreachable'
22
+ },
23
+ 524: {
24
+ status: 524,
25
+ title: 'A timeout occurred',
26
+ type: '/errors/defaults/cloudflare/timeout'
27
+ },
28
+ 525: {
29
+ status: 525,
30
+ title: 'SSL handshake failed',
31
+ type: '/errors/defaults/cloudflare/sslhandshakefail'
32
+ },
33
+ 526: {
34
+ status: 526,
35
+ title: 'Invalid SSL certificate',
36
+ type: '/errors/defaults/cloudflare/invalidssl'
37
+ },
38
+ // A 527 error indicates an interrupted connection between Cloudflare and your origin's Railgun server (rg-listener)
39
+ 527: {
40
+ status: 527,
41
+ title: 'Railgun Listener to origin error',
42
+ type: '/errors/defaults/cloudflare/railgunoriginerr'
43
+ },
44
+ 530: {
45
+ status: 530,
46
+ title: 'Cloudflare returned 1xxx error',
47
+ type: '/errors/defaults/cloudflare/1xxx'
48
+ }
49
+ };
@@ -0,0 +1,17 @@
1
+ export declare const statusCodes: {
2
+ 440: {
3
+ status: number;
4
+ title: string;
5
+ type: string;
6
+ };
7
+ 449: {
8
+ status: number;
9
+ title: string;
10
+ type: string;
11
+ };
12
+ 451: {
13
+ status: number;
14
+ title: string;
15
+ type: string;
16
+ };
17
+ };
@@ -0,0 +1,18 @@
1
+ // Source: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
2
+ export const statusCodes = {
3
+ 440: {
4
+ status: 440,
5
+ title: 'Login Time-out',
6
+ type: '/errors/defaults/iis/logintimeout',
7
+ },
8
+ 449: {
9
+ status: 449,
10
+ title: 'Retry with required information',
11
+ type: '/errors/defaults/iis/retrywith'
12
+ },
13
+ 451: {
14
+ status: 451,
15
+ title: 'Redirect',
16
+ type: '/errors/defaults/iis/redirect'
17
+ }
18
+ };
@@ -0,0 +1,7 @@
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';
@@ -0,0 +1,7 @@
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';
@@ -0,0 +1,32 @@
1
+ export declare const statusCodes: {
2
+ 444: {
3
+ status: number;
4
+ title: string;
5
+ type: string;
6
+ };
7
+ 494: {
8
+ status: number;
9
+ title: string;
10
+ type: string;
11
+ };
12
+ 495: {
13
+ status: number;
14
+ title: string;
15
+ type: string;
16
+ };
17
+ 496: {
18
+ status: number;
19
+ title: string;
20
+ type: string;
21
+ };
22
+ 497: {
23
+ status: number;
24
+ title: string;
25
+ type: string;
26
+ };
27
+ 499: {
28
+ status: number;
29
+ title: string;
30
+ type: string;
31
+ };
32
+ };
@@ -0,0 +1,33 @@
1
+ // Source: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
2
+ export const statusCodes = {
3
+ 444: {
4
+ status: 494,
5
+ title: 'No Response',
6
+ type: '/errors/defaults/nginx/noresponse',
7
+ },
8
+ 494: {
9
+ status: 494,
10
+ title: 'Request header too large',
11
+ type: '/errors/defaults/nginx/headertoolarge',
12
+ },
13
+ 495: {
14
+ status: 495,
15
+ title: 'SSL Certificate Error',
16
+ type: '/errors/defaults/nginx/sslcerterr'
17
+ },
18
+ 496: {
19
+ status: 496,
20
+ title: 'SSL Certificate Required',
21
+ type: '/errors/defaults/nginx/sslcertrequired'
22
+ },
23
+ 497: {
24
+ status: 497,
25
+ title: 'HTTP Request Sent to HTTPS Port',
26
+ type: '/errors/defaults/nginx/httpreqtohttpsport'
27
+ },
28
+ 499: {
29
+ status: 499,
30
+ title: 'Client Closed Request',
31
+ type: '/errors/defaults/nginx/clientclosedreq'
32
+ }
33
+ };
@@ -0,0 +1,37 @@
1
+ export declare const otherErrors: {
2
+ unknown: {
3
+ status: number;
4
+ title: string;
5
+ type: string;
6
+ };
7
+ corsError: {
8
+ status: number;
9
+ title: string;
10
+ type: string;
11
+ };
12
+ problemParseError: {
13
+ status: number;
14
+ title: string;
15
+ type: string;
16
+ };
17
+ problemJsonError: {
18
+ status: number;
19
+ title: string;
20
+ type: string;
21
+ };
22
+ notAnError: {
23
+ status: number;
24
+ title: string;
25
+ type: string;
26
+ };
27
+ networkError: {
28
+ status: number;
29
+ title: string;
30
+ type: string;
31
+ };
32
+ inputValidationError: {
33
+ status: number;
34
+ title: string;
35
+ type: string;
36
+ };
37
+ };
@@ -0,0 +1,37 @@
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
+ };
package/esm/index.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ export { Problem } from './problem.js';
2
+ export * as defaults from './defaults/index.js';
3
+ export { default as events } from './util/events.js';
4
+ export * from './typings/index.js';
5
+ export * from './util/isProblemArray.js';
package/esm/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { Problem } from './problem.js';
2
+ export * as defaults from './defaults/index.js';
3
+ export { default as events } from './util/events.js';
4
+ export * from './typings/index.js';
5
+ export * from './util/isProblemArray.js';
@@ -0,0 +1,13 @@
1
+ import type { PartialMiddlewareOptions } from '../typings/middleware.js';
2
+ import { MiddlewareBase } from './base.js';
3
+ type InterceptorArray = [undefined, (error: unknown) => Promise<never>];
4
+ export declare class AxiosMiddleware extends MiddlewareBase {
5
+ name: string;
6
+ constructor(options?: PartialMiddlewareOptions);
7
+ interceptor: (error: unknown) => Promise<never>;
8
+ /**
9
+ * @example instance.interceptors.response.use(...middleware.use())
10
+ */
11
+ use: () => InterceptorArray;
12
+ }
13
+ export {};
@@ -0,0 +1,20 @@
1
+ import { MiddlewareBase } from './base.js';
2
+ import axiosParser from '../parsers/axios.js';
3
+ import events from '../util/events.js';
4
+ export class AxiosMiddleware extends MiddlewareBase {
5
+ name = 'axios';
6
+ constructor(options) {
7
+ super({
8
+ 'parsers': [axiosParser]
9
+ }, options);
10
+ }
11
+ interceptor = async (error) => {
12
+ const problems = await this.parse(error);
13
+ events.emit(problems);
14
+ return Promise.reject(problems);
15
+ };
16
+ /**
17
+ * @example instance.interceptors.response.use(...middleware.use())
18
+ */
19
+ use = () => [undefined, this.interceptor];
20
+ }
@@ -0,0 +1,24 @@
1
+ import { Problem } from '../problem.js';
2
+ import type { ProblemOpts } from '../typings/index.js';
3
+ import type { MiddlewareOptions, PartialMiddlewareOptions } from '../typings/middleware.js';
4
+ /**
5
+ * Middleware collects errors from somewhere, transforms them into something recognizable by a parser, and then passes them to the parsers, and then returns an array of Problems to whatever is using the middleware
6
+ */
7
+ export declare abstract class MiddlewareBase {
8
+ options: MiddlewareOptions;
9
+ abstract name: string;
10
+ /**
11
+ * When nothing is returned from the parsers, just throw in a default "fallback" Problem object, so that a Problem is still actually returned/emitted
12
+ */
13
+ enableFallback: boolean;
14
+ constructor(defaultOptions: MiddlewareOptions, options?: PartialMiddlewareOptions);
15
+ /**
16
+ * Call this function when you want to use the middleware function
17
+ */
18
+ abstract use(): unknown;
19
+ /**
20
+ * Parse input using parsers
21
+ */
22
+ parse: (input: unknown) => Promise<Problem[]>;
23
+ fallback: ProblemOpts;
24
+ }