hono-ban 0.2.4 → 0.2.6
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/dist/esm/formatters/index.js +1 -0
- package/dist/esm/index.js +1 -311
- package/package.json +9 -24
- package/dist/cjs/formatters/rfc7807/index.js +0 -364
- package/dist/cjs/formatters/rfc7807/index.js.map +0 -16
- package/dist/cjs/index.js +0 -271
- package/dist/cjs/index.js.map +0 -16
- package/dist/esm/formatters/rfc7807/index.js +0 -333
- package/dist/esm/formatters/rfc7807/index.js.map +0 -16
- package/dist/esm/index.js.map +0 -16
- package/src/__tests__/core/convert-error.test.ts +0 -158
- package/src/__tests__/core/create-error.test.ts +0 -113
- package/src/__tests__/core/format-error.test.ts +0 -162
- package/src/__tests__/factories/factories.test.ts +0 -380
- package/src/__tests__/formatters/default-formatter.test.ts +0 -117
- package/src/__tests__/middleware/README.md +0 -49
- package/src/__tests__/middleware/ban-middleware.test.ts.disabled +0 -23
- package/src/__tests__/utils/sanitize.test.ts +0 -117
- package/src/__tests__/utils/validate.test.ts +0 -35
- package/src/constants/index.ts +0 -6
- package/src/constants/status-codes.ts +0 -52
- package/src/core/convert-error.ts +0 -74
- package/src/core/create-error.ts +0 -65
- package/src/core/format-error.ts +0 -76
- package/src/core/index.ts +0 -8
- package/src/factories/client-errors.ts +0 -492
- package/src/factories/index.ts +0 -7
- package/src/factories/server-errors.ts +0 -230
- package/src/formatters/default/index.ts +0 -72
- package/src/formatters/index.ts +0 -13
- package/src/formatters/interfaces.ts +0 -7
- package/src/formatters/rfc7807/formatter.ts +0 -105
- package/src/formatters/rfc7807/hooks.ts +0 -73
- package/src/formatters/rfc7807/index.ts +0 -20
- package/src/formatters/rfc7807/schemas.ts +0 -88
- package/src/index.ts +0 -23
- package/src/middleware/ban-middleware.ts +0 -77
- package/src/middleware/index.ts +0 -6
- package/src/types/common.ts +0 -14
- package/src/types/error.ts +0 -46
- package/src/types/formatter.ts +0 -61
- package/src/types/index.ts +0 -11
- package/src/types/options.ts +0 -71
- package/src/types/rfc7807.ts +0 -93
- package/src/utils/index.ts +0 -7
- package/src/utils/sanitize.ts +0 -34
- package/src/utils/validate.ts +0 -24
|
@@ -1,492 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Client error factory functions (4xx)
|
|
3
|
-
* @module hono-ban/factories/client-errors
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { BanError, BanOptions, ErrorStatusCode } from "../types";
|
|
7
|
-
import { createError } from "../core";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Helper function to reduce duplication
|
|
11
|
-
* @param statusCode - HTTP status code
|
|
12
|
-
* @param messageOrOptions - Error message or options
|
|
13
|
-
* @param options - Additional options
|
|
14
|
-
*/
|
|
15
|
-
function createErrorWithStatus<T>(
|
|
16
|
-
statusCode: ErrorStatusCode,
|
|
17
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
18
|
-
options?: Partial<BanOptions<T>>
|
|
19
|
-
): BanError<T> {
|
|
20
|
-
if (typeof messageOrOptions === "string") {
|
|
21
|
-
return createError<T>({
|
|
22
|
-
...options,
|
|
23
|
-
statusCode,
|
|
24
|
-
message: messageOrOptions,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return createError<T>({ ...messageOrOptions, ...options, statusCode });
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Create a 400 Bad Request error
|
|
32
|
-
* @param messageOrOptions - Error message or options
|
|
33
|
-
* @param options - Additional options
|
|
34
|
-
*/
|
|
35
|
-
export function badRequest<T = unknown>(
|
|
36
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
37
|
-
options?: Partial<BanOptions<T>>
|
|
38
|
-
): BanError<T> {
|
|
39
|
-
return createErrorWithStatus(
|
|
40
|
-
400 as ErrorStatusCode,
|
|
41
|
-
messageOrOptions,
|
|
42
|
-
options
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Create a 401 Unauthorized error
|
|
48
|
-
* @param messageOrOptions - Error message or options
|
|
49
|
-
* @param options - Additional options
|
|
50
|
-
*/
|
|
51
|
-
export function unauthorized<T = unknown>(
|
|
52
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
53
|
-
options?: Partial<BanOptions<T>>
|
|
54
|
-
): BanError<T> {
|
|
55
|
-
return createErrorWithStatus(
|
|
56
|
-
401 as ErrorStatusCode,
|
|
57
|
-
messageOrOptions,
|
|
58
|
-
options
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Create a 402 Payment Required error
|
|
64
|
-
* @param messageOrOptions - Error message or options
|
|
65
|
-
* @param options - Additional options
|
|
66
|
-
*/
|
|
67
|
-
export function paymentRequired<T = unknown>(
|
|
68
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
69
|
-
options?: Partial<BanOptions<T>>
|
|
70
|
-
): BanError<T> {
|
|
71
|
-
return createErrorWithStatus(
|
|
72
|
-
402 as ErrorStatusCode,
|
|
73
|
-
messageOrOptions,
|
|
74
|
-
options
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Create a 403 Forbidden error
|
|
80
|
-
* @param messageOrOptions - Error message or options
|
|
81
|
-
* @param options - Additional options
|
|
82
|
-
*/
|
|
83
|
-
export function forbidden<T = unknown>(
|
|
84
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
85
|
-
options?: Partial<BanOptions<T>>
|
|
86
|
-
): BanError<T> {
|
|
87
|
-
return createErrorWithStatus(
|
|
88
|
-
403 as ErrorStatusCode,
|
|
89
|
-
messageOrOptions,
|
|
90
|
-
options
|
|
91
|
-
);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Create a 404 Not Found error
|
|
96
|
-
* @param messageOrOptions - Error message or options
|
|
97
|
-
* @param options - Additional options
|
|
98
|
-
*/
|
|
99
|
-
export function notFound<T = unknown>(
|
|
100
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
101
|
-
options?: Partial<BanOptions<T>>
|
|
102
|
-
): BanError<T> {
|
|
103
|
-
return createErrorWithStatus(
|
|
104
|
-
404 as ErrorStatusCode,
|
|
105
|
-
messageOrOptions,
|
|
106
|
-
options
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Create a 405 Method Not Allowed error
|
|
112
|
-
* @param messageOrOptions - Error message or options
|
|
113
|
-
* @param options - Additional options
|
|
114
|
-
*/
|
|
115
|
-
export function methodNotAllowed<T = unknown>(
|
|
116
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
117
|
-
options?: Partial<BanOptions<T>>
|
|
118
|
-
): BanError<T> {
|
|
119
|
-
return createErrorWithStatus(
|
|
120
|
-
405 as ErrorStatusCode,
|
|
121
|
-
messageOrOptions,
|
|
122
|
-
options
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Create a 406 Not Acceptable error
|
|
128
|
-
* @param messageOrOptions - Error message or options
|
|
129
|
-
* @param options - Additional options
|
|
130
|
-
*/
|
|
131
|
-
export function notAcceptable<T = unknown>(
|
|
132
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
133
|
-
options?: Partial<BanOptions<T>>
|
|
134
|
-
): BanError<T> {
|
|
135
|
-
return createErrorWithStatus(
|
|
136
|
-
406 as ErrorStatusCode,
|
|
137
|
-
messageOrOptions,
|
|
138
|
-
options
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Create a 407 Proxy Authentication Required error
|
|
144
|
-
* @param messageOrOptions - Error message or options
|
|
145
|
-
* @param options - Additional options
|
|
146
|
-
*/
|
|
147
|
-
export function proxyAuthRequired<T = unknown>(
|
|
148
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
149
|
-
options?: Partial<BanOptions<T>>
|
|
150
|
-
): BanError<T> {
|
|
151
|
-
return createErrorWithStatus(
|
|
152
|
-
407 as ErrorStatusCode,
|
|
153
|
-
messageOrOptions,
|
|
154
|
-
options
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Create a 408 Request Timeout error
|
|
160
|
-
* @param messageOrOptions - Error message or options
|
|
161
|
-
* @param options - Additional options
|
|
162
|
-
*/
|
|
163
|
-
export function clientTimeout<T = unknown>(
|
|
164
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
165
|
-
options?: Partial<BanOptions<T>>
|
|
166
|
-
): BanError<T> {
|
|
167
|
-
return createErrorWithStatus(
|
|
168
|
-
408 as ErrorStatusCode,
|
|
169
|
-
messageOrOptions,
|
|
170
|
-
options
|
|
171
|
-
);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Create a 409 Conflict error
|
|
176
|
-
* @param messageOrOptions - Error message or options
|
|
177
|
-
* @param options - Additional options
|
|
178
|
-
*/
|
|
179
|
-
export function conflict<T = unknown>(
|
|
180
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
181
|
-
options?: Partial<BanOptions<T>>
|
|
182
|
-
): BanError<T> {
|
|
183
|
-
return createErrorWithStatus(
|
|
184
|
-
409 as ErrorStatusCode,
|
|
185
|
-
messageOrOptions,
|
|
186
|
-
options
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Create a 410 Gone error
|
|
192
|
-
* @param messageOrOptions - Error message or options
|
|
193
|
-
* @param options - Additional options
|
|
194
|
-
*/
|
|
195
|
-
export function resourceGone<T = unknown>(
|
|
196
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
197
|
-
options?: Partial<BanOptions<T>>
|
|
198
|
-
): BanError<T> {
|
|
199
|
-
return createErrorWithStatus(
|
|
200
|
-
410 as ErrorStatusCode,
|
|
201
|
-
messageOrOptions,
|
|
202
|
-
options
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Create a 411 Length Required error
|
|
208
|
-
* @param messageOrOptions - Error message or options
|
|
209
|
-
* @param options - Additional options
|
|
210
|
-
*/
|
|
211
|
-
export function lengthRequired<T = unknown>(
|
|
212
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
213
|
-
options?: Partial<BanOptions<T>>
|
|
214
|
-
): BanError<T> {
|
|
215
|
-
return createErrorWithStatus(
|
|
216
|
-
411 as ErrorStatusCode,
|
|
217
|
-
messageOrOptions,
|
|
218
|
-
options
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Create a 412 Precondition Failed error
|
|
224
|
-
* @param messageOrOptions - Error message or options
|
|
225
|
-
* @param options - Additional options
|
|
226
|
-
*/
|
|
227
|
-
export function preconditionFailed<T = unknown>(
|
|
228
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
229
|
-
options?: Partial<BanOptions<T>>
|
|
230
|
-
): BanError<T> {
|
|
231
|
-
return createErrorWithStatus(
|
|
232
|
-
412 as ErrorStatusCode,
|
|
233
|
-
messageOrOptions,
|
|
234
|
-
options
|
|
235
|
-
);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Create a 413 Payload Too Large error
|
|
240
|
-
* @param messageOrOptions - Error message or options
|
|
241
|
-
* @param options - Additional options
|
|
242
|
-
*/
|
|
243
|
-
export function entityTooLarge<T = unknown>(
|
|
244
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
245
|
-
options?: Partial<BanOptions<T>>
|
|
246
|
-
): BanError<T> {
|
|
247
|
-
return createErrorWithStatus(
|
|
248
|
-
413 as ErrorStatusCode,
|
|
249
|
-
messageOrOptions,
|
|
250
|
-
options
|
|
251
|
-
);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* Create a 414 URI Too Long error
|
|
256
|
-
* @param messageOrOptions - Error message or options
|
|
257
|
-
* @param options - Additional options
|
|
258
|
-
*/
|
|
259
|
-
export function uriTooLong<T = unknown>(
|
|
260
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
261
|
-
options?: Partial<BanOptions<T>>
|
|
262
|
-
): BanError<T> {
|
|
263
|
-
return createErrorWithStatus(
|
|
264
|
-
414 as ErrorStatusCode,
|
|
265
|
-
messageOrOptions,
|
|
266
|
-
options
|
|
267
|
-
);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Create a 415 Unsupported Media Type error
|
|
272
|
-
* @param messageOrOptions - Error message or options
|
|
273
|
-
* @param options - Additional options
|
|
274
|
-
*/
|
|
275
|
-
export function unsupportedMediaType<T = unknown>(
|
|
276
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
277
|
-
options?: Partial<BanOptions<T>>
|
|
278
|
-
): BanError<T> {
|
|
279
|
-
return createErrorWithStatus(
|
|
280
|
-
415 as ErrorStatusCode,
|
|
281
|
-
messageOrOptions,
|
|
282
|
-
options
|
|
283
|
-
);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Create a 416 Range Not Satisfiable error
|
|
288
|
-
* @param messageOrOptions - Error message or options
|
|
289
|
-
* @param options - Additional options
|
|
290
|
-
*/
|
|
291
|
-
export function rangeNotSatisfiable<T = unknown>(
|
|
292
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
293
|
-
options?: Partial<BanOptions<T>>
|
|
294
|
-
): BanError<T> {
|
|
295
|
-
return createErrorWithStatus(
|
|
296
|
-
416 as ErrorStatusCode,
|
|
297
|
-
messageOrOptions,
|
|
298
|
-
options
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Create a 417 Expectation Failed error
|
|
304
|
-
* @param messageOrOptions - Error message or options
|
|
305
|
-
* @param options - Additional options
|
|
306
|
-
*/
|
|
307
|
-
export function expectationFailed<T = unknown>(
|
|
308
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
309
|
-
options?: Partial<BanOptions<T>>
|
|
310
|
-
): BanError<T> {
|
|
311
|
-
return createErrorWithStatus(
|
|
312
|
-
417 as ErrorStatusCode,
|
|
313
|
-
messageOrOptions,
|
|
314
|
-
options
|
|
315
|
-
);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Create a 418 I'm a Teapot error
|
|
320
|
-
* @param messageOrOptions - Error message or options
|
|
321
|
-
* @param options - Additional options
|
|
322
|
-
*/
|
|
323
|
-
export function teapot<T = unknown>(
|
|
324
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
325
|
-
options?: Partial<BanOptions<T>>
|
|
326
|
-
): BanError<T> {
|
|
327
|
-
return createErrorWithStatus(
|
|
328
|
-
418 as ErrorStatusCode,
|
|
329
|
-
messageOrOptions,
|
|
330
|
-
options
|
|
331
|
-
);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* Create a 421 Misdirected Request error
|
|
336
|
-
* @param messageOrOptions - Error message or options
|
|
337
|
-
* @param options - Additional options
|
|
338
|
-
*/
|
|
339
|
-
export function misdirectedRequest<T = unknown>(
|
|
340
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
341
|
-
options?: Partial<BanOptions<T>>
|
|
342
|
-
): BanError<T> {
|
|
343
|
-
return createErrorWithStatus(
|
|
344
|
-
421 as ErrorStatusCode,
|
|
345
|
-
messageOrOptions,
|
|
346
|
-
options
|
|
347
|
-
);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Create a 422 Unprocessable Entity error
|
|
352
|
-
* @param messageOrOptions - Error message or options
|
|
353
|
-
* @param options - Additional options
|
|
354
|
-
*/
|
|
355
|
-
export function badData<T = unknown>(
|
|
356
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
357
|
-
options?: Partial<BanOptions<T>>
|
|
358
|
-
): BanError<T> {
|
|
359
|
-
return createErrorWithStatus(
|
|
360
|
-
422 as ErrorStatusCode,
|
|
361
|
-
messageOrOptions,
|
|
362
|
-
options
|
|
363
|
-
);
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* Create a 423 Locked error
|
|
368
|
-
* @param messageOrOptions - Error message or options
|
|
369
|
-
* @param options - Additional options
|
|
370
|
-
*/
|
|
371
|
-
export function locked<T = unknown>(
|
|
372
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
373
|
-
options?: Partial<BanOptions<T>>
|
|
374
|
-
): BanError<T> {
|
|
375
|
-
return createErrorWithStatus(
|
|
376
|
-
423 as ErrorStatusCode,
|
|
377
|
-
messageOrOptions,
|
|
378
|
-
options
|
|
379
|
-
);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* Create a 424 Failed Dependency error
|
|
384
|
-
* @param messageOrOptions - Error message or options
|
|
385
|
-
* @param options - Additional options
|
|
386
|
-
*/
|
|
387
|
-
export function failedDependency<T = unknown>(
|
|
388
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
389
|
-
options?: Partial<BanOptions<T>>
|
|
390
|
-
): BanError<T> {
|
|
391
|
-
return createErrorWithStatus(
|
|
392
|
-
424 as ErrorStatusCode,
|
|
393
|
-
messageOrOptions,
|
|
394
|
-
options
|
|
395
|
-
);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* Create a 425 Too Early error
|
|
400
|
-
* @param messageOrOptions - Error message or options
|
|
401
|
-
* @param options - Additional options
|
|
402
|
-
*/
|
|
403
|
-
export function tooEarly<T = unknown>(
|
|
404
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
405
|
-
options?: Partial<BanOptions<T>>
|
|
406
|
-
): BanError<T> {
|
|
407
|
-
return createErrorWithStatus(
|
|
408
|
-
425 as ErrorStatusCode,
|
|
409
|
-
messageOrOptions,
|
|
410
|
-
options
|
|
411
|
-
);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
/**
|
|
415
|
-
* Create a 426 Upgrade Required error
|
|
416
|
-
* @param messageOrOptions - Error message or options
|
|
417
|
-
* @param options - Additional options
|
|
418
|
-
*/
|
|
419
|
-
export function upgradeRequired<T = unknown>(
|
|
420
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
421
|
-
options?: Partial<BanOptions<T>>
|
|
422
|
-
): BanError<T> {
|
|
423
|
-
return createErrorWithStatus(
|
|
424
|
-
426 as ErrorStatusCode,
|
|
425
|
-
messageOrOptions,
|
|
426
|
-
options
|
|
427
|
-
);
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
/**
|
|
431
|
-
* Create a 428 Precondition Required error
|
|
432
|
-
* @param messageOrOptions - Error message or options
|
|
433
|
-
* @param options - Additional options
|
|
434
|
-
*/
|
|
435
|
-
export function preconditionRequired<T = unknown>(
|
|
436
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
437
|
-
options?: Partial<BanOptions<T>>
|
|
438
|
-
): BanError<T> {
|
|
439
|
-
return createErrorWithStatus(
|
|
440
|
-
428 as ErrorStatusCode,
|
|
441
|
-
messageOrOptions,
|
|
442
|
-
options
|
|
443
|
-
);
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
/**
|
|
447
|
-
* Create a 429 Too Many Requests error
|
|
448
|
-
* @param messageOrOptions - Error message or options
|
|
449
|
-
* @param options - Additional options
|
|
450
|
-
*/
|
|
451
|
-
export function tooManyRequests<T = unknown>(
|
|
452
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
453
|
-
options?: Partial<BanOptions<T>>
|
|
454
|
-
): BanError<T> {
|
|
455
|
-
return createErrorWithStatus(
|
|
456
|
-
429 as ErrorStatusCode,
|
|
457
|
-
messageOrOptions,
|
|
458
|
-
options
|
|
459
|
-
);
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
/**
|
|
463
|
-
* Create a 431 Request Header Fields Too Large error
|
|
464
|
-
* @param messageOrOptions - Error message or options
|
|
465
|
-
* @param options - Additional options
|
|
466
|
-
*/
|
|
467
|
-
export function headerFieldsTooLarge<T = unknown>(
|
|
468
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
469
|
-
options?: Partial<BanOptions<T>>
|
|
470
|
-
): BanError<T> {
|
|
471
|
-
return createErrorWithStatus(
|
|
472
|
-
431 as ErrorStatusCode,
|
|
473
|
-
messageOrOptions,
|
|
474
|
-
options
|
|
475
|
-
);
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
/**
|
|
479
|
-
* Create a 451 Unavailable For Legal Reasons error
|
|
480
|
-
* @param messageOrOptions - Error message or options
|
|
481
|
-
* @param options - Additional options
|
|
482
|
-
*/
|
|
483
|
-
export function illegal<T = unknown>(
|
|
484
|
-
messageOrOptions?: string | Partial<BanOptions<T>>,
|
|
485
|
-
options?: Partial<BanOptions<T>>
|
|
486
|
-
): BanError<T> {
|
|
487
|
-
return createErrorWithStatus(
|
|
488
|
-
451 as ErrorStatusCode,
|
|
489
|
-
messageOrOptions,
|
|
490
|
-
options
|
|
491
|
-
);
|
|
492
|
-
}
|