better-call 0.2.13-beta.5 → 0.2.13-beta.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/adapter/node.d.cts +1 -1
- package/dist/adapter/node.d.mts +1 -1
- package/dist/adapter/node.d.ts +1 -1
- package/dist/client.d.cts +1 -1
- package/dist/client.d.mts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/index.cjs +67 -19
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +67 -20
- package/dist/shared/{better-call.21658031.d.cts → better-call.bb4fb8f1.d.cts} +63 -5
- package/dist/shared/{better-call.21658031.d.mts → better-call.bb4fb8f1.d.mts} +63 -5
- package/dist/shared/{better-call.21658031.d.ts → better-call.bb4fb8f1.d.ts} +63 -5
- package/package.json +1 -1
package/dist/adapter/node.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
2
|
import * as undici_types from 'undici-types';
|
|
3
|
-
import { R as Router } from '../shared/better-call.
|
|
3
|
+
import { R as Router } from '../shared/better-call.bb4fb8f1.cjs';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import '@asteasolutions/zod-to-openapi/dist/zod-extensions';
|
|
6
6
|
import '@asteasolutions/zod-to-openapi';
|
package/dist/adapter/node.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
2
|
import * as undici_types from 'undici-types';
|
|
3
|
-
import { R as Router } from '../shared/better-call.
|
|
3
|
+
import { R as Router } from '../shared/better-call.bb4fb8f1.mjs';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import '@asteasolutions/zod-to-openapi/dist/zod-extensions';
|
|
6
6
|
import '@asteasolutions/zod-to-openapi';
|
package/dist/adapter/node.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
2
|
import * as undici_types from 'undici-types';
|
|
3
|
-
import { R as Router } from '../shared/better-call.
|
|
3
|
+
import { R as Router } from '../shared/better-call.bb4fb8f1.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import '@asteasolutions/zod-to-openapi/dist/zod-extensions';
|
|
6
6
|
import '@asteasolutions/zod-to-openapi';
|
package/dist/client.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BetterFetchOption, BetterFetchResponse } from '@better-fetch/fetch';
|
|
2
|
-
import { R as Router, U as UnionToIntersection, b as Endpoint, H as HasRequiredKeys } from './shared/better-call.
|
|
2
|
+
import { R as Router, U as UnionToIntersection, b as Endpoint, H as HasRequiredKeys } from './shared/better-call.bb4fb8f1.cjs';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import '@asteasolutions/zod-to-openapi/dist/zod-extensions';
|
|
5
5
|
import '@asteasolutions/zod-to-openapi';
|
package/dist/client.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BetterFetchOption, BetterFetchResponse } from '@better-fetch/fetch';
|
|
2
|
-
import { R as Router, U as UnionToIntersection, b as Endpoint, H as HasRequiredKeys } from './shared/better-call.
|
|
2
|
+
import { R as Router, U as UnionToIntersection, b as Endpoint, H as HasRequiredKeys } from './shared/better-call.bb4fb8f1.mjs';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import '@asteasolutions/zod-to-openapi/dist/zod-extensions';
|
|
5
5
|
import '@asteasolutions/zod-to-openapi';
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BetterFetchOption, BetterFetchResponse } from '@better-fetch/fetch';
|
|
2
|
-
import { R as Router, U as UnionToIntersection, b as Endpoint, H as HasRequiredKeys } from './shared/better-call.
|
|
2
|
+
import { R as Router, U as UnionToIntersection, b as Endpoint, H as HasRequiredKeys } from './shared/better-call.bb4fb8f1.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import '@asteasolutions/zod-to-openapi/dist/zod-extensions';
|
|
5
5
|
import '@asteasolutions/zod-to-openapi';
|
package/dist/index.cjs
CHANGED
|
@@ -78,18 +78,69 @@ function createGetHeader(headers) {
|
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
const _statusCode = {
|
|
82
|
+
OK: 200,
|
|
83
|
+
CREATED: 201,
|
|
84
|
+
ACCEPTED: 202,
|
|
85
|
+
NO_CONTENT: 204,
|
|
86
|
+
MULTIPLE_CHOICES: 300,
|
|
87
|
+
MOVED_PERMANENTLY: 301,
|
|
88
|
+
FOUND: 302,
|
|
89
|
+
SEE_OTHER: 303,
|
|
90
|
+
NOT_MODIFIED: 304,
|
|
91
|
+
TEMPORARY_REDIRECT: 307,
|
|
92
|
+
BAD_REQUEST: 400,
|
|
93
|
+
UNAUTHORIZED: 401,
|
|
94
|
+
PAYMENT_REQUIRED: 402,
|
|
95
|
+
FORBIDDEN: 403,
|
|
96
|
+
NOT_FOUND: 404,
|
|
97
|
+
METHOD_NOT_ALLOWED: 405,
|
|
98
|
+
NOT_ACCEPTABLE: 406,
|
|
99
|
+
PROXY_AUTHENTICATION_REQUIRED: 407,
|
|
100
|
+
REQUEST_TIMEOUT: 408,
|
|
101
|
+
CONFLICT: 409,
|
|
102
|
+
GONE: 410,
|
|
103
|
+
LENGTH_REQUIRED: 411,
|
|
104
|
+
PRECONDITION_FAILED: 412,
|
|
105
|
+
PAYLOAD_TOO_LARGE: 413,
|
|
106
|
+
URI_TOO_LONG: 414,
|
|
107
|
+
UNSUPPORTED_MEDIA_TYPE: 415,
|
|
108
|
+
RANGE_NOT_SATISFIABLE: 416,
|
|
109
|
+
EXPECTATION_FAILED: 417,
|
|
110
|
+
"I'M_A_TEAPOT": 418,
|
|
111
|
+
MISDIRECTED_REQUEST: 421,
|
|
112
|
+
UNPROCESSABLE_ENTITY: 422,
|
|
113
|
+
LOCKED: 423,
|
|
114
|
+
FAILED_DEPENDENCY: 424,
|
|
115
|
+
TOO_EARLY: 425,
|
|
116
|
+
UPGRADE_REQUIRED: 426,
|
|
117
|
+
PRECONDITION_REQUIRED: 428,
|
|
118
|
+
TOO_MANY_REQUESTS: 429,
|
|
119
|
+
REQUEST_HEADER_FIELDS_TOO_LARGE: 431,
|
|
120
|
+
UNAVAILABLE_FOR_LEGAL_REASONS: 451,
|
|
121
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
122
|
+
NOT_IMPLEMENTED: 501,
|
|
123
|
+
BAD_GATEWAY: 502,
|
|
124
|
+
SERVICE_UNAVAILABLE: 503,
|
|
125
|
+
GATEWAY_TIMEOUT: 504,
|
|
126
|
+
HTTP_VERSION_NOT_SUPPORTED: 505,
|
|
127
|
+
VARIANT_ALSO_NEGOTIATES: 506,
|
|
128
|
+
INSUFFICIENT_STORAGE: 507,
|
|
129
|
+
LOOP_DETECTED: 508,
|
|
130
|
+
NOT_EXTENDED: 510,
|
|
131
|
+
NETWORK_AUTHENTICATION_REQUIRED: 511
|
|
132
|
+
};
|
|
81
133
|
class APIError extends Error {
|
|
82
|
-
constructor(
|
|
83
|
-
super(message);
|
|
84
|
-
this.message = message;
|
|
134
|
+
constructor(status = "INTERNAL_SERVER_ERROR", body = void 0, headers = {}, statusCode = _statusCode[status]) {
|
|
135
|
+
super(body?.message || status);
|
|
85
136
|
this.status = status;
|
|
86
|
-
this.
|
|
137
|
+
this.body = body;
|
|
87
138
|
this.headers = headers;
|
|
139
|
+
this.statusCode = statusCode;
|
|
88
140
|
this.name = "APIError";
|
|
89
|
-
this.message = message;
|
|
90
141
|
this.status = status;
|
|
91
|
-
this.code = code;
|
|
92
142
|
this.headers = headers;
|
|
143
|
+
this.statusCode = statusCode;
|
|
93
144
|
this.stack = "";
|
|
94
145
|
}
|
|
95
146
|
}
|
|
@@ -379,7 +430,9 @@ const createEndpoint = (path, options, handler) => {
|
|
|
379
430
|
const { asResponse, ...ctx } = inputCtx[0] || {};
|
|
380
431
|
const { data, error } = runValidation(options, ctx);
|
|
381
432
|
if (error) {
|
|
382
|
-
throw new APIError(
|
|
433
|
+
throw new APIError("BAD_REQUEST", {
|
|
434
|
+
message: error.message
|
|
435
|
+
});
|
|
383
436
|
}
|
|
384
437
|
const context = {
|
|
385
438
|
json: (json, routerResponse) => {
|
|
@@ -425,7 +478,7 @@ const createEndpoint = (path, options, handler) => {
|
|
|
425
478
|
return getSignedCookie(headers, secret, key, prefix);
|
|
426
479
|
},
|
|
427
480
|
redirect: (url) => {
|
|
428
|
-
const apiError = new APIError("
|
|
481
|
+
const apiError = new APIError("FOUND", void 0, {
|
|
429
482
|
Location: url,
|
|
430
483
|
...response.headers
|
|
431
484
|
});
|
|
@@ -442,7 +495,7 @@ const createEndpoint = (path, options, handler) => {
|
|
|
442
495
|
headers.set(key, value);
|
|
443
496
|
}
|
|
444
497
|
return new Response(null, {
|
|
445
|
-
status: e.
|
|
498
|
+
status: e.statusCode,
|
|
446
499
|
headers
|
|
447
500
|
});
|
|
448
501
|
}
|
|
@@ -661,16 +714,10 @@ const createRouter = (endpoints, config) => {
|
|
|
661
714
|
}
|
|
662
715
|
}
|
|
663
716
|
if (e instanceof APIError) {
|
|
664
|
-
return new Response(
|
|
665
|
-
e.
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
}) : null,
|
|
669
|
-
{
|
|
670
|
-
status: e.status,
|
|
671
|
-
headers: e.headers
|
|
672
|
-
}
|
|
673
|
-
);
|
|
717
|
+
return new Response(e.body ? JSON.stringify(e.body) : null, {
|
|
718
|
+
status: e.statusCode,
|
|
719
|
+
headers: e.headers
|
|
720
|
+
});
|
|
674
721
|
}
|
|
675
722
|
if (config?.throwError) {
|
|
676
723
|
throw e;
|
|
@@ -725,6 +772,7 @@ function createMiddlewareCreator(opts) {
|
|
|
725
772
|
createMiddleware.creator = createMiddlewareCreator;
|
|
726
773
|
|
|
727
774
|
exports.APIError = APIError;
|
|
775
|
+
exports._statusCode = _statusCode;
|
|
728
776
|
exports.createEndpoint = createEndpoint;
|
|
729
777
|
exports.createGetHeader = createGetHeader;
|
|
730
778
|
exports.createMiddleware = createMiddleware;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as EndpointOptions, a as EndpointResponse, b as Endpoint, c as EndpointContext, I as InferUse, C as CookiePrefixOptions, d as CookieOptions } from './shared/better-call.
|
|
2
|
-
export { A as APIError, j as Context, o as Cookie, p as CookieConstraint, H as HasRequiredKeys, m as InferResponse, g as Input, i as IsEmptyObject, J as JSONResponse, P as Prettify, h as RequiredKeysOf, R as Router, S as SignedCookie, U as UnionToIntersection, e as createEndpoint, l as createGetHeader, f as createRouter, k as createSetHeader, n as fromError, q as parse, s as parseSigned, r as runValidation, t as serialize, u as serializeSigned } from './shared/better-call.
|
|
1
|
+
import { E as EndpointOptions, a as EndpointResponse, b as Endpoint, c as EndpointContext, I as InferUse, C as CookiePrefixOptions, d as CookieOptions } from './shared/better-call.bb4fb8f1.cjs';
|
|
2
|
+
export { A as APIError, j as Context, o as Cookie, p as CookieConstraint, H as HasRequiredKeys, m as InferResponse, g as Input, i as IsEmptyObject, J as JSONResponse, P as Prettify, h as RequiredKeysOf, R as Router, S as SignedCookie, U as UnionToIntersection, _ as _statusCode, e as createEndpoint, l as createGetHeader, f as createRouter, k as createSetHeader, n as fromError, q as parse, s as parseSigned, r as runValidation, t as serialize, u as serializeSigned } from './shared/better-call.bb4fb8f1.cjs';
|
|
3
3
|
import { BufferSource } from 'stream/web';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import '@asteasolutions/zod-to-openapi/dist/zod-extensions';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as EndpointOptions, a as EndpointResponse, b as Endpoint, c as EndpointContext, I as InferUse, C as CookiePrefixOptions, d as CookieOptions } from './shared/better-call.
|
|
2
|
-
export { A as APIError, j as Context, o as Cookie, p as CookieConstraint, H as HasRequiredKeys, m as InferResponse, g as Input, i as IsEmptyObject, J as JSONResponse, P as Prettify, h as RequiredKeysOf, R as Router, S as SignedCookie, U as UnionToIntersection, e as createEndpoint, l as createGetHeader, f as createRouter, k as createSetHeader, n as fromError, q as parse, s as parseSigned, r as runValidation, t as serialize, u as serializeSigned } from './shared/better-call.
|
|
1
|
+
import { E as EndpointOptions, a as EndpointResponse, b as Endpoint, c as EndpointContext, I as InferUse, C as CookiePrefixOptions, d as CookieOptions } from './shared/better-call.bb4fb8f1.mjs';
|
|
2
|
+
export { A as APIError, j as Context, o as Cookie, p as CookieConstraint, H as HasRequiredKeys, m as InferResponse, g as Input, i as IsEmptyObject, J as JSONResponse, P as Prettify, h as RequiredKeysOf, R as Router, S as SignedCookie, U as UnionToIntersection, _ as _statusCode, e as createEndpoint, l as createGetHeader, f as createRouter, k as createSetHeader, n as fromError, q as parse, s as parseSigned, r as runValidation, t as serialize, u as serializeSigned } from './shared/better-call.bb4fb8f1.mjs';
|
|
3
3
|
import { BufferSource } from 'stream/web';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import '@asteasolutions/zod-to-openapi/dist/zod-extensions';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as EndpointOptions, a as EndpointResponse, b as Endpoint, c as EndpointContext, I as InferUse, C as CookiePrefixOptions, d as CookieOptions } from './shared/better-call.
|
|
2
|
-
export { A as APIError, j as Context, o as Cookie, p as CookieConstraint, H as HasRequiredKeys, m as InferResponse, g as Input, i as IsEmptyObject, J as JSONResponse, P as Prettify, h as RequiredKeysOf, R as Router, S as SignedCookie, U as UnionToIntersection, e as createEndpoint, l as createGetHeader, f as createRouter, k as createSetHeader, n as fromError, q as parse, s as parseSigned, r as runValidation, t as serialize, u as serializeSigned } from './shared/better-call.
|
|
1
|
+
import { E as EndpointOptions, a as EndpointResponse, b as Endpoint, c as EndpointContext, I as InferUse, C as CookiePrefixOptions, d as CookieOptions } from './shared/better-call.bb4fb8f1.js';
|
|
2
|
+
export { A as APIError, j as Context, o as Cookie, p as CookieConstraint, H as HasRequiredKeys, m as InferResponse, g as Input, i as IsEmptyObject, J as JSONResponse, P as Prettify, h as RequiredKeysOf, R as Router, S as SignedCookie, U as UnionToIntersection, _ as _statusCode, e as createEndpoint, l as createGetHeader, f as createRouter, k as createSetHeader, n as fromError, q as parse, s as parseSigned, r as runValidation, t as serialize, u as serializeSigned } from './shared/better-call.bb4fb8f1.js';
|
|
3
3
|
import { BufferSource } from 'stream/web';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import '@asteasolutions/zod-to-openapi/dist/zod-extensions';
|
package/dist/index.mjs
CHANGED
|
@@ -72,18 +72,69 @@ function createGetHeader(headers) {
|
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
const _statusCode = {
|
|
76
|
+
OK: 200,
|
|
77
|
+
CREATED: 201,
|
|
78
|
+
ACCEPTED: 202,
|
|
79
|
+
NO_CONTENT: 204,
|
|
80
|
+
MULTIPLE_CHOICES: 300,
|
|
81
|
+
MOVED_PERMANENTLY: 301,
|
|
82
|
+
FOUND: 302,
|
|
83
|
+
SEE_OTHER: 303,
|
|
84
|
+
NOT_MODIFIED: 304,
|
|
85
|
+
TEMPORARY_REDIRECT: 307,
|
|
86
|
+
BAD_REQUEST: 400,
|
|
87
|
+
UNAUTHORIZED: 401,
|
|
88
|
+
PAYMENT_REQUIRED: 402,
|
|
89
|
+
FORBIDDEN: 403,
|
|
90
|
+
NOT_FOUND: 404,
|
|
91
|
+
METHOD_NOT_ALLOWED: 405,
|
|
92
|
+
NOT_ACCEPTABLE: 406,
|
|
93
|
+
PROXY_AUTHENTICATION_REQUIRED: 407,
|
|
94
|
+
REQUEST_TIMEOUT: 408,
|
|
95
|
+
CONFLICT: 409,
|
|
96
|
+
GONE: 410,
|
|
97
|
+
LENGTH_REQUIRED: 411,
|
|
98
|
+
PRECONDITION_FAILED: 412,
|
|
99
|
+
PAYLOAD_TOO_LARGE: 413,
|
|
100
|
+
URI_TOO_LONG: 414,
|
|
101
|
+
UNSUPPORTED_MEDIA_TYPE: 415,
|
|
102
|
+
RANGE_NOT_SATISFIABLE: 416,
|
|
103
|
+
EXPECTATION_FAILED: 417,
|
|
104
|
+
"I'M_A_TEAPOT": 418,
|
|
105
|
+
MISDIRECTED_REQUEST: 421,
|
|
106
|
+
UNPROCESSABLE_ENTITY: 422,
|
|
107
|
+
LOCKED: 423,
|
|
108
|
+
FAILED_DEPENDENCY: 424,
|
|
109
|
+
TOO_EARLY: 425,
|
|
110
|
+
UPGRADE_REQUIRED: 426,
|
|
111
|
+
PRECONDITION_REQUIRED: 428,
|
|
112
|
+
TOO_MANY_REQUESTS: 429,
|
|
113
|
+
REQUEST_HEADER_FIELDS_TOO_LARGE: 431,
|
|
114
|
+
UNAVAILABLE_FOR_LEGAL_REASONS: 451,
|
|
115
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
116
|
+
NOT_IMPLEMENTED: 501,
|
|
117
|
+
BAD_GATEWAY: 502,
|
|
118
|
+
SERVICE_UNAVAILABLE: 503,
|
|
119
|
+
GATEWAY_TIMEOUT: 504,
|
|
120
|
+
HTTP_VERSION_NOT_SUPPORTED: 505,
|
|
121
|
+
VARIANT_ALSO_NEGOTIATES: 506,
|
|
122
|
+
INSUFFICIENT_STORAGE: 507,
|
|
123
|
+
LOOP_DETECTED: 508,
|
|
124
|
+
NOT_EXTENDED: 510,
|
|
125
|
+
NETWORK_AUTHENTICATION_REQUIRED: 511
|
|
126
|
+
};
|
|
75
127
|
class APIError extends Error {
|
|
76
|
-
constructor(
|
|
77
|
-
super(message);
|
|
78
|
-
this.message = message;
|
|
128
|
+
constructor(status = "INTERNAL_SERVER_ERROR", body = void 0, headers = {}, statusCode = _statusCode[status]) {
|
|
129
|
+
super(body?.message || status);
|
|
79
130
|
this.status = status;
|
|
80
|
-
this.
|
|
131
|
+
this.body = body;
|
|
81
132
|
this.headers = headers;
|
|
133
|
+
this.statusCode = statusCode;
|
|
82
134
|
this.name = "APIError";
|
|
83
|
-
this.message = message;
|
|
84
135
|
this.status = status;
|
|
85
|
-
this.code = code;
|
|
86
136
|
this.headers = headers;
|
|
137
|
+
this.statusCode = statusCode;
|
|
87
138
|
this.stack = "";
|
|
88
139
|
}
|
|
89
140
|
}
|
|
@@ -373,7 +424,9 @@ const createEndpoint = (path, options, handler) => {
|
|
|
373
424
|
const { asResponse, ...ctx } = inputCtx[0] || {};
|
|
374
425
|
const { data, error } = runValidation(options, ctx);
|
|
375
426
|
if (error) {
|
|
376
|
-
throw new APIError(
|
|
427
|
+
throw new APIError("BAD_REQUEST", {
|
|
428
|
+
message: error.message
|
|
429
|
+
});
|
|
377
430
|
}
|
|
378
431
|
const context = {
|
|
379
432
|
json: (json, routerResponse) => {
|
|
@@ -419,7 +472,7 @@ const createEndpoint = (path, options, handler) => {
|
|
|
419
472
|
return getSignedCookie(headers, secret, key, prefix);
|
|
420
473
|
},
|
|
421
474
|
redirect: (url) => {
|
|
422
|
-
const apiError = new APIError("
|
|
475
|
+
const apiError = new APIError("FOUND", void 0, {
|
|
423
476
|
Location: url,
|
|
424
477
|
...response.headers
|
|
425
478
|
});
|
|
@@ -436,7 +489,7 @@ const createEndpoint = (path, options, handler) => {
|
|
|
436
489
|
headers.set(key, value);
|
|
437
490
|
}
|
|
438
491
|
return new Response(null, {
|
|
439
|
-
status: e.
|
|
492
|
+
status: e.statusCode,
|
|
440
493
|
headers
|
|
441
494
|
});
|
|
442
495
|
}
|
|
@@ -655,16 +708,10 @@ const createRouter = (endpoints, config) => {
|
|
|
655
708
|
}
|
|
656
709
|
}
|
|
657
710
|
if (e instanceof APIError) {
|
|
658
|
-
return new Response(
|
|
659
|
-
e.
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
}) : null,
|
|
663
|
-
{
|
|
664
|
-
status: e.status,
|
|
665
|
-
headers: e.headers
|
|
666
|
-
}
|
|
667
|
-
);
|
|
711
|
+
return new Response(e.body ? JSON.stringify(e.body) : null, {
|
|
712
|
+
status: e.statusCode,
|
|
713
|
+
headers: e.headers
|
|
714
|
+
});
|
|
668
715
|
}
|
|
669
716
|
if (config?.throwError) {
|
|
670
717
|
throw e;
|
|
@@ -718,4 +765,4 @@ function createMiddlewareCreator(opts) {
|
|
|
718
765
|
}
|
|
719
766
|
createMiddleware.creator = createMiddlewareCreator;
|
|
720
767
|
|
|
721
|
-
export { APIError, createEndpoint, createGetHeader, createMiddleware, createRouter, createSetHeader, fromError, getCookie, getSignedCookie, parse, parseSigned, runValidation, serialize, serializeSigned, setCookie, setSignedCookie };
|
|
768
|
+
export { APIError, _statusCode, createEndpoint, createGetHeader, createMiddleware, createRouter, createSetHeader, fromError, getCookie, getSignedCookie, parse, parseSigned, runValidation, serialize, serializeSigned, setCookie, setSignedCookie };
|
|
@@ -124,12 +124,70 @@ declare const parseSigned: (cookie: string, secret: string | BufferSource, name?
|
|
|
124
124
|
declare const serialize: <Name extends string>(name: Name, value: string, opt?: CookieConstraint<Name>) => string;
|
|
125
125
|
declare const serializeSigned: (name: string, value: string, secret: string | BufferSource, opt?: CookieOptions) => Promise<string>;
|
|
126
126
|
|
|
127
|
+
declare const _statusCode: {
|
|
128
|
+
OK: number;
|
|
129
|
+
CREATED: number;
|
|
130
|
+
ACCEPTED: number;
|
|
131
|
+
NO_CONTENT: number;
|
|
132
|
+
MULTIPLE_CHOICES: number;
|
|
133
|
+
MOVED_PERMANENTLY: number;
|
|
134
|
+
FOUND: number;
|
|
135
|
+
SEE_OTHER: number;
|
|
136
|
+
NOT_MODIFIED: number;
|
|
137
|
+
TEMPORARY_REDIRECT: number;
|
|
138
|
+
BAD_REQUEST: number;
|
|
139
|
+
UNAUTHORIZED: number;
|
|
140
|
+
PAYMENT_REQUIRED: number;
|
|
141
|
+
FORBIDDEN: number;
|
|
142
|
+
NOT_FOUND: number;
|
|
143
|
+
METHOD_NOT_ALLOWED: number;
|
|
144
|
+
NOT_ACCEPTABLE: number;
|
|
145
|
+
PROXY_AUTHENTICATION_REQUIRED: number;
|
|
146
|
+
REQUEST_TIMEOUT: number;
|
|
147
|
+
CONFLICT: number;
|
|
148
|
+
GONE: number;
|
|
149
|
+
LENGTH_REQUIRED: number;
|
|
150
|
+
PRECONDITION_FAILED: number;
|
|
151
|
+
PAYLOAD_TOO_LARGE: number;
|
|
152
|
+
URI_TOO_LONG: number;
|
|
153
|
+
UNSUPPORTED_MEDIA_TYPE: number;
|
|
154
|
+
RANGE_NOT_SATISFIABLE: number;
|
|
155
|
+
EXPECTATION_FAILED: number;
|
|
156
|
+
"I'M_A_TEAPOT": number;
|
|
157
|
+
MISDIRECTED_REQUEST: number;
|
|
158
|
+
UNPROCESSABLE_ENTITY: number;
|
|
159
|
+
LOCKED: number;
|
|
160
|
+
FAILED_DEPENDENCY: number;
|
|
161
|
+
TOO_EARLY: number;
|
|
162
|
+
UPGRADE_REQUIRED: number;
|
|
163
|
+
PRECONDITION_REQUIRED: number;
|
|
164
|
+
TOO_MANY_REQUESTS: number;
|
|
165
|
+
REQUEST_HEADER_FIELDS_TOO_LARGE: number;
|
|
166
|
+
UNAVAILABLE_FOR_LEGAL_REASONS: number;
|
|
167
|
+
INTERNAL_SERVER_ERROR: number;
|
|
168
|
+
NOT_IMPLEMENTED: number;
|
|
169
|
+
BAD_GATEWAY: number;
|
|
170
|
+
SERVICE_UNAVAILABLE: number;
|
|
171
|
+
GATEWAY_TIMEOUT: number;
|
|
172
|
+
HTTP_VERSION_NOT_SUPPORTED: number;
|
|
173
|
+
VARIANT_ALSO_NEGOTIATES: number;
|
|
174
|
+
INSUFFICIENT_STORAGE: number;
|
|
175
|
+
LOOP_DETECTED: number;
|
|
176
|
+
NOT_EXTENDED: number;
|
|
177
|
+
NETWORK_AUTHENTICATION_REQUIRED: number;
|
|
178
|
+
};
|
|
127
179
|
declare class APIError extends Error {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
180
|
+
status: keyof typeof _statusCode;
|
|
181
|
+
body: {
|
|
182
|
+
message?: string;
|
|
183
|
+
code?: string;
|
|
184
|
+
} | undefined;
|
|
131
185
|
headers: {};
|
|
132
|
-
|
|
186
|
+
statusCode: number;
|
|
187
|
+
constructor(status?: keyof typeof _statusCode, body?: {
|
|
188
|
+
message?: string;
|
|
189
|
+
code?: string;
|
|
190
|
+
} | undefined, headers?: {}, statusCode?: number);
|
|
133
191
|
}
|
|
134
192
|
|
|
135
193
|
interface EndpointContext<Path extends string, Options extends EndpointOptions> {
|
|
@@ -615,4 +673,4 @@ declare const createRouter: <E extends Record<string, Endpoint>, Config extends
|
|
|
615
673
|
};
|
|
616
674
|
type Router = ReturnType<typeof createRouter>;
|
|
617
675
|
|
|
618
|
-
export { APIError as A, type CookiePrefixOptions as C, type EndpointOptions as E, type HasRequiredKeys as H, type InferUse as I, type JSONResponse as J, type Prettify as P, type Router as R, type SignedCookie as S, type UnionToIntersection as U, type EndpointResponse as a, type Endpoint as b, type EndpointContext as c, type CookieOptions as d, createEndpoint as e, createRouter as f, type Input as g, type RequiredKeysOf as h, type IsEmptyObject as i, type Context as j, createSetHeader as k, createGetHeader as l, type InferResponse as m, fromError as n, type Cookie as o, type CookieConstraint as p, parse as q, runValidation as r, parseSigned as s, serialize as t, serializeSigned as u };
|
|
676
|
+
export { APIError as A, type CookiePrefixOptions as C, type EndpointOptions as E, type HasRequiredKeys as H, type InferUse as I, type JSONResponse as J, type Prettify as P, type Router as R, type SignedCookie as S, type UnionToIntersection as U, _statusCode as _, type EndpointResponse as a, type Endpoint as b, type EndpointContext as c, type CookieOptions as d, createEndpoint as e, createRouter as f, type Input as g, type RequiredKeysOf as h, type IsEmptyObject as i, type Context as j, createSetHeader as k, createGetHeader as l, type InferResponse as m, fromError as n, type Cookie as o, type CookieConstraint as p, parse as q, runValidation as r, parseSigned as s, serialize as t, serializeSigned as u };
|
|
@@ -124,12 +124,70 @@ declare const parseSigned: (cookie: string, secret: string | BufferSource, name?
|
|
|
124
124
|
declare const serialize: <Name extends string>(name: Name, value: string, opt?: CookieConstraint<Name>) => string;
|
|
125
125
|
declare const serializeSigned: (name: string, value: string, secret: string | BufferSource, opt?: CookieOptions) => Promise<string>;
|
|
126
126
|
|
|
127
|
+
declare const _statusCode: {
|
|
128
|
+
OK: number;
|
|
129
|
+
CREATED: number;
|
|
130
|
+
ACCEPTED: number;
|
|
131
|
+
NO_CONTENT: number;
|
|
132
|
+
MULTIPLE_CHOICES: number;
|
|
133
|
+
MOVED_PERMANENTLY: number;
|
|
134
|
+
FOUND: number;
|
|
135
|
+
SEE_OTHER: number;
|
|
136
|
+
NOT_MODIFIED: number;
|
|
137
|
+
TEMPORARY_REDIRECT: number;
|
|
138
|
+
BAD_REQUEST: number;
|
|
139
|
+
UNAUTHORIZED: number;
|
|
140
|
+
PAYMENT_REQUIRED: number;
|
|
141
|
+
FORBIDDEN: number;
|
|
142
|
+
NOT_FOUND: number;
|
|
143
|
+
METHOD_NOT_ALLOWED: number;
|
|
144
|
+
NOT_ACCEPTABLE: number;
|
|
145
|
+
PROXY_AUTHENTICATION_REQUIRED: number;
|
|
146
|
+
REQUEST_TIMEOUT: number;
|
|
147
|
+
CONFLICT: number;
|
|
148
|
+
GONE: number;
|
|
149
|
+
LENGTH_REQUIRED: number;
|
|
150
|
+
PRECONDITION_FAILED: number;
|
|
151
|
+
PAYLOAD_TOO_LARGE: number;
|
|
152
|
+
URI_TOO_LONG: number;
|
|
153
|
+
UNSUPPORTED_MEDIA_TYPE: number;
|
|
154
|
+
RANGE_NOT_SATISFIABLE: number;
|
|
155
|
+
EXPECTATION_FAILED: number;
|
|
156
|
+
"I'M_A_TEAPOT": number;
|
|
157
|
+
MISDIRECTED_REQUEST: number;
|
|
158
|
+
UNPROCESSABLE_ENTITY: number;
|
|
159
|
+
LOCKED: number;
|
|
160
|
+
FAILED_DEPENDENCY: number;
|
|
161
|
+
TOO_EARLY: number;
|
|
162
|
+
UPGRADE_REQUIRED: number;
|
|
163
|
+
PRECONDITION_REQUIRED: number;
|
|
164
|
+
TOO_MANY_REQUESTS: number;
|
|
165
|
+
REQUEST_HEADER_FIELDS_TOO_LARGE: number;
|
|
166
|
+
UNAVAILABLE_FOR_LEGAL_REASONS: number;
|
|
167
|
+
INTERNAL_SERVER_ERROR: number;
|
|
168
|
+
NOT_IMPLEMENTED: number;
|
|
169
|
+
BAD_GATEWAY: number;
|
|
170
|
+
SERVICE_UNAVAILABLE: number;
|
|
171
|
+
GATEWAY_TIMEOUT: number;
|
|
172
|
+
HTTP_VERSION_NOT_SUPPORTED: number;
|
|
173
|
+
VARIANT_ALSO_NEGOTIATES: number;
|
|
174
|
+
INSUFFICIENT_STORAGE: number;
|
|
175
|
+
LOOP_DETECTED: number;
|
|
176
|
+
NOT_EXTENDED: number;
|
|
177
|
+
NETWORK_AUTHENTICATION_REQUIRED: number;
|
|
178
|
+
};
|
|
127
179
|
declare class APIError extends Error {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
180
|
+
status: keyof typeof _statusCode;
|
|
181
|
+
body: {
|
|
182
|
+
message?: string;
|
|
183
|
+
code?: string;
|
|
184
|
+
} | undefined;
|
|
131
185
|
headers: {};
|
|
132
|
-
|
|
186
|
+
statusCode: number;
|
|
187
|
+
constructor(status?: keyof typeof _statusCode, body?: {
|
|
188
|
+
message?: string;
|
|
189
|
+
code?: string;
|
|
190
|
+
} | undefined, headers?: {}, statusCode?: number);
|
|
133
191
|
}
|
|
134
192
|
|
|
135
193
|
interface EndpointContext<Path extends string, Options extends EndpointOptions> {
|
|
@@ -615,4 +673,4 @@ declare const createRouter: <E extends Record<string, Endpoint>, Config extends
|
|
|
615
673
|
};
|
|
616
674
|
type Router = ReturnType<typeof createRouter>;
|
|
617
675
|
|
|
618
|
-
export { APIError as A, type CookiePrefixOptions as C, type EndpointOptions as E, type HasRequiredKeys as H, type InferUse as I, type JSONResponse as J, type Prettify as P, type Router as R, type SignedCookie as S, type UnionToIntersection as U, type EndpointResponse as a, type Endpoint as b, type EndpointContext as c, type CookieOptions as d, createEndpoint as e, createRouter as f, type Input as g, type RequiredKeysOf as h, type IsEmptyObject as i, type Context as j, createSetHeader as k, createGetHeader as l, type InferResponse as m, fromError as n, type Cookie as o, type CookieConstraint as p, parse as q, runValidation as r, parseSigned as s, serialize as t, serializeSigned as u };
|
|
676
|
+
export { APIError as A, type CookiePrefixOptions as C, type EndpointOptions as E, type HasRequiredKeys as H, type InferUse as I, type JSONResponse as J, type Prettify as P, type Router as R, type SignedCookie as S, type UnionToIntersection as U, _statusCode as _, type EndpointResponse as a, type Endpoint as b, type EndpointContext as c, type CookieOptions as d, createEndpoint as e, createRouter as f, type Input as g, type RequiredKeysOf as h, type IsEmptyObject as i, type Context as j, createSetHeader as k, createGetHeader as l, type InferResponse as m, fromError as n, type Cookie as o, type CookieConstraint as p, parse as q, runValidation as r, parseSigned as s, serialize as t, serializeSigned as u };
|
|
@@ -124,12 +124,70 @@ declare const parseSigned: (cookie: string, secret: string | BufferSource, name?
|
|
|
124
124
|
declare const serialize: <Name extends string>(name: Name, value: string, opt?: CookieConstraint<Name>) => string;
|
|
125
125
|
declare const serializeSigned: (name: string, value: string, secret: string | BufferSource, opt?: CookieOptions) => Promise<string>;
|
|
126
126
|
|
|
127
|
+
declare const _statusCode: {
|
|
128
|
+
OK: number;
|
|
129
|
+
CREATED: number;
|
|
130
|
+
ACCEPTED: number;
|
|
131
|
+
NO_CONTENT: number;
|
|
132
|
+
MULTIPLE_CHOICES: number;
|
|
133
|
+
MOVED_PERMANENTLY: number;
|
|
134
|
+
FOUND: number;
|
|
135
|
+
SEE_OTHER: number;
|
|
136
|
+
NOT_MODIFIED: number;
|
|
137
|
+
TEMPORARY_REDIRECT: number;
|
|
138
|
+
BAD_REQUEST: number;
|
|
139
|
+
UNAUTHORIZED: number;
|
|
140
|
+
PAYMENT_REQUIRED: number;
|
|
141
|
+
FORBIDDEN: number;
|
|
142
|
+
NOT_FOUND: number;
|
|
143
|
+
METHOD_NOT_ALLOWED: number;
|
|
144
|
+
NOT_ACCEPTABLE: number;
|
|
145
|
+
PROXY_AUTHENTICATION_REQUIRED: number;
|
|
146
|
+
REQUEST_TIMEOUT: number;
|
|
147
|
+
CONFLICT: number;
|
|
148
|
+
GONE: number;
|
|
149
|
+
LENGTH_REQUIRED: number;
|
|
150
|
+
PRECONDITION_FAILED: number;
|
|
151
|
+
PAYLOAD_TOO_LARGE: number;
|
|
152
|
+
URI_TOO_LONG: number;
|
|
153
|
+
UNSUPPORTED_MEDIA_TYPE: number;
|
|
154
|
+
RANGE_NOT_SATISFIABLE: number;
|
|
155
|
+
EXPECTATION_FAILED: number;
|
|
156
|
+
"I'M_A_TEAPOT": number;
|
|
157
|
+
MISDIRECTED_REQUEST: number;
|
|
158
|
+
UNPROCESSABLE_ENTITY: number;
|
|
159
|
+
LOCKED: number;
|
|
160
|
+
FAILED_DEPENDENCY: number;
|
|
161
|
+
TOO_EARLY: number;
|
|
162
|
+
UPGRADE_REQUIRED: number;
|
|
163
|
+
PRECONDITION_REQUIRED: number;
|
|
164
|
+
TOO_MANY_REQUESTS: number;
|
|
165
|
+
REQUEST_HEADER_FIELDS_TOO_LARGE: number;
|
|
166
|
+
UNAVAILABLE_FOR_LEGAL_REASONS: number;
|
|
167
|
+
INTERNAL_SERVER_ERROR: number;
|
|
168
|
+
NOT_IMPLEMENTED: number;
|
|
169
|
+
BAD_GATEWAY: number;
|
|
170
|
+
SERVICE_UNAVAILABLE: number;
|
|
171
|
+
GATEWAY_TIMEOUT: number;
|
|
172
|
+
HTTP_VERSION_NOT_SUPPORTED: number;
|
|
173
|
+
VARIANT_ALSO_NEGOTIATES: number;
|
|
174
|
+
INSUFFICIENT_STORAGE: number;
|
|
175
|
+
LOOP_DETECTED: number;
|
|
176
|
+
NOT_EXTENDED: number;
|
|
177
|
+
NETWORK_AUTHENTICATION_REQUIRED: number;
|
|
178
|
+
};
|
|
127
179
|
declare class APIError extends Error {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
180
|
+
status: keyof typeof _statusCode;
|
|
181
|
+
body: {
|
|
182
|
+
message?: string;
|
|
183
|
+
code?: string;
|
|
184
|
+
} | undefined;
|
|
131
185
|
headers: {};
|
|
132
|
-
|
|
186
|
+
statusCode: number;
|
|
187
|
+
constructor(status?: keyof typeof _statusCode, body?: {
|
|
188
|
+
message?: string;
|
|
189
|
+
code?: string;
|
|
190
|
+
} | undefined, headers?: {}, statusCode?: number);
|
|
133
191
|
}
|
|
134
192
|
|
|
135
193
|
interface EndpointContext<Path extends string, Options extends EndpointOptions> {
|
|
@@ -615,4 +673,4 @@ declare const createRouter: <E extends Record<string, Endpoint>, Config extends
|
|
|
615
673
|
};
|
|
616
674
|
type Router = ReturnType<typeof createRouter>;
|
|
617
675
|
|
|
618
|
-
export { APIError as A, type CookiePrefixOptions as C, type EndpointOptions as E, type HasRequiredKeys as H, type InferUse as I, type JSONResponse as J, type Prettify as P, type Router as R, type SignedCookie as S, type UnionToIntersection as U, type EndpointResponse as a, type Endpoint as b, type EndpointContext as c, type CookieOptions as d, createEndpoint as e, createRouter as f, type Input as g, type RequiredKeysOf as h, type IsEmptyObject as i, type Context as j, createSetHeader as k, createGetHeader as l, type InferResponse as m, fromError as n, type Cookie as o, type CookieConstraint as p, parse as q, runValidation as r, parseSigned as s, serialize as t, serializeSigned as u };
|
|
676
|
+
export { APIError as A, type CookiePrefixOptions as C, type EndpointOptions as E, type HasRequiredKeys as H, type InferUse as I, type JSONResponse as J, type Prettify as P, type Router as R, type SignedCookie as S, type UnionToIntersection as U, _statusCode as _, type EndpointResponse as a, type Endpoint as b, type EndpointContext as c, type CookieOptions as d, createEndpoint as e, createRouter as f, type Input as g, type RequiredKeysOf as h, type IsEmptyObject as i, type Context as j, createSetHeader as k, createGetHeader as l, type InferResponse as m, fromError as n, type Cookie as o, type CookieConstraint as p, parse as q, runValidation as r, parseSigned as s, serialize as t, serializeSigned as u };
|