better-call 1.0.18 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -2
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/index.cjs +43 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +44 -6
- package/dist/index.js.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/router-BDQGRZdc.d.cts +2816 -0
- package/dist/router-BDQGRZdc.d.ts +2816 -0
- package/package.json +2 -1
- package/dist/router-DcqXHY8X.d.cts +0 -1285
- package/dist/router-DcqXHY8X.d.ts +0 -1285
|
@@ -0,0 +1,2816 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hide internal stack frames from the error stack trace.
|
|
3
|
+
*/
|
|
4
|
+
declare function hideInternalStackFrames(stack: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Creates a custom error class that hides stack frames.
|
|
7
|
+
*/
|
|
8
|
+
declare function makeErrorForHideStackFrame<B extends new (...args: any[]) => Error>(Base: B, clazz: any): {
|
|
9
|
+
new (...args: ConstructorParameters<B>): InstanceType<B> & {
|
|
10
|
+
errorStack: string | undefined;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
declare const _statusCode: {
|
|
14
|
+
OK: number;
|
|
15
|
+
CREATED: number;
|
|
16
|
+
ACCEPTED: number;
|
|
17
|
+
NO_CONTENT: number;
|
|
18
|
+
MULTIPLE_CHOICES: number;
|
|
19
|
+
MOVED_PERMANENTLY: number;
|
|
20
|
+
FOUND: number;
|
|
21
|
+
SEE_OTHER: number;
|
|
22
|
+
NOT_MODIFIED: number;
|
|
23
|
+
TEMPORARY_REDIRECT: number;
|
|
24
|
+
BAD_REQUEST: number;
|
|
25
|
+
UNAUTHORIZED: number;
|
|
26
|
+
PAYMENT_REQUIRED: number;
|
|
27
|
+
FORBIDDEN: number;
|
|
28
|
+
NOT_FOUND: number;
|
|
29
|
+
METHOD_NOT_ALLOWED: number;
|
|
30
|
+
NOT_ACCEPTABLE: number;
|
|
31
|
+
PROXY_AUTHENTICATION_REQUIRED: number;
|
|
32
|
+
REQUEST_TIMEOUT: number;
|
|
33
|
+
CONFLICT: number;
|
|
34
|
+
GONE: number;
|
|
35
|
+
LENGTH_REQUIRED: number;
|
|
36
|
+
PRECONDITION_FAILED: number;
|
|
37
|
+
PAYLOAD_TOO_LARGE: number;
|
|
38
|
+
URI_TOO_LONG: number;
|
|
39
|
+
UNSUPPORTED_MEDIA_TYPE: number;
|
|
40
|
+
RANGE_NOT_SATISFIABLE: number;
|
|
41
|
+
EXPECTATION_FAILED: number;
|
|
42
|
+
"I'M_A_TEAPOT": number;
|
|
43
|
+
MISDIRECTED_REQUEST: number;
|
|
44
|
+
UNPROCESSABLE_ENTITY: number;
|
|
45
|
+
LOCKED: number;
|
|
46
|
+
FAILED_DEPENDENCY: number;
|
|
47
|
+
TOO_EARLY: number;
|
|
48
|
+
UPGRADE_REQUIRED: number;
|
|
49
|
+
PRECONDITION_REQUIRED: number;
|
|
50
|
+
TOO_MANY_REQUESTS: number;
|
|
51
|
+
REQUEST_HEADER_FIELDS_TOO_LARGE: number;
|
|
52
|
+
UNAVAILABLE_FOR_LEGAL_REASONS: number;
|
|
53
|
+
INTERNAL_SERVER_ERROR: number;
|
|
54
|
+
NOT_IMPLEMENTED: number;
|
|
55
|
+
BAD_GATEWAY: number;
|
|
56
|
+
SERVICE_UNAVAILABLE: number;
|
|
57
|
+
GATEWAY_TIMEOUT: number;
|
|
58
|
+
HTTP_VERSION_NOT_SUPPORTED: number;
|
|
59
|
+
VARIANT_ALSO_NEGOTIATES: number;
|
|
60
|
+
INSUFFICIENT_STORAGE: number;
|
|
61
|
+
LOOP_DETECTED: number;
|
|
62
|
+
NOT_EXTENDED: number;
|
|
63
|
+
NETWORK_AUTHENTICATION_REQUIRED: number;
|
|
64
|
+
};
|
|
65
|
+
type Status = 100 | 101 | 102 | 103 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
|
|
66
|
+
declare class InternalAPIError extends Error {
|
|
67
|
+
status: keyof typeof _statusCode | Status;
|
|
68
|
+
body: ({
|
|
69
|
+
message?: string;
|
|
70
|
+
code?: string;
|
|
71
|
+
cause?: unknown;
|
|
72
|
+
} & Record<string, any>) | undefined;
|
|
73
|
+
headers: HeadersInit;
|
|
74
|
+
statusCode: number;
|
|
75
|
+
constructor(status?: keyof typeof _statusCode | Status, body?: ({
|
|
76
|
+
message?: string;
|
|
77
|
+
code?: string;
|
|
78
|
+
cause?: unknown;
|
|
79
|
+
} & Record<string, any>) | undefined, headers?: HeadersInit, statusCode?: number);
|
|
80
|
+
}
|
|
81
|
+
type APIError = InstanceType<typeof InternalAPIError>;
|
|
82
|
+
declare const APIError: new (status?: Status | "OK" | "CREATED" | "ACCEPTED" | "NO_CONTENT" | "MULTIPLE_CHOICES" | "MOVED_PERMANENTLY" | "FOUND" | "SEE_OTHER" | "NOT_MODIFIED" | "TEMPORARY_REDIRECT" | "BAD_REQUEST" | "UNAUTHORIZED" | "PAYMENT_REQUIRED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_ALLOWED" | "NOT_ACCEPTABLE" | "PROXY_AUTHENTICATION_REQUIRED" | "REQUEST_TIMEOUT" | "CONFLICT" | "GONE" | "LENGTH_REQUIRED" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "URI_TOO_LONG" | "UNSUPPORTED_MEDIA_TYPE" | "RANGE_NOT_SATISFIABLE" | "EXPECTATION_FAILED" | "I'M_A_TEAPOT" | "MISDIRECTED_REQUEST" | "UNPROCESSABLE_ENTITY" | "LOCKED" | "FAILED_DEPENDENCY" | "TOO_EARLY" | "UPGRADE_REQUIRED" | "PRECONDITION_REQUIRED" | "TOO_MANY_REQUESTS" | "REQUEST_HEADER_FIELDS_TOO_LARGE" | "UNAVAILABLE_FOR_LEGAL_REASONS" | "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED" | "BAD_GATEWAY" | "SERVICE_UNAVAILABLE" | "GATEWAY_TIMEOUT" | "HTTP_VERSION_NOT_SUPPORTED" | "VARIANT_ALSO_NEGOTIATES" | "INSUFFICIENT_STORAGE" | "LOOP_DETECTED" | "NOT_EXTENDED" | "NETWORK_AUTHENTICATION_REQUIRED" | undefined, body?: ({
|
|
83
|
+
message?: string;
|
|
84
|
+
code?: string;
|
|
85
|
+
cause?: unknown;
|
|
86
|
+
} & Record<string, any>) | undefined, headers?: HeadersInit | undefined, statusCode?: number | undefined) => InternalAPIError & {
|
|
87
|
+
errorStack: string | undefined;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
type RequiredKeysOf<BaseType extends object> = Exclude<{
|
|
91
|
+
[Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]> ? Key : never;
|
|
92
|
+
}[keyof BaseType], undefined>;
|
|
93
|
+
type HasRequiredKeys<BaseType extends object> = RequiredKeysOf<BaseType> extends never ? false : true;
|
|
94
|
+
type Prettify<T> = {
|
|
95
|
+
[K in keyof T]: T[K];
|
|
96
|
+
} & {};
|
|
97
|
+
type IsEmptyObject<T> = keyof T extends never ? true : false;
|
|
98
|
+
type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends (mergedIntersection: infer Intersection) => void ? Intersection & Union : never;
|
|
99
|
+
type MergeObject<T extends Record<string, any> | never, S extends Record<string, any> | never> = T extends never ? S : S extends never ? T : T & S;
|
|
100
|
+
type InferParamPath<Path> = Path extends `${infer _Start}:${infer Param}/${infer Rest}` ? {
|
|
101
|
+
[K in Param | keyof InferParamPath<Rest>]: string;
|
|
102
|
+
} : Path extends `${infer _Start}:${infer Param}` ? {
|
|
103
|
+
[K in Param]: string;
|
|
104
|
+
} : Path extends `${infer _Start}/${infer Rest}` ? InferParamPath<Rest> : {};
|
|
105
|
+
type InferParamWildCard<Path> = Path extends `${infer _Start}/*:${infer Param}/${infer Rest}` | `${infer _Start}/**:${infer Param}/${infer Rest}` ? {
|
|
106
|
+
[K in Param | keyof InferParamPath<Rest>]: string;
|
|
107
|
+
} : Path extends `${infer _Start}/*` ? {
|
|
108
|
+
[K in "_"]: string;
|
|
109
|
+
} : Path extends `${infer _Start}/${infer Rest}` ? InferParamWildCard<Rest> : {};
|
|
110
|
+
|
|
111
|
+
interface MiddlewareOptions extends Omit<EndpointOptions, "method"> {
|
|
112
|
+
}
|
|
113
|
+
type MiddlewareResponse = null | void | undefined | Record<string, any>;
|
|
114
|
+
type MiddlewareContext<Options extends MiddlewareOptions, Context = {}> = EndpointContext<string, Options & {
|
|
115
|
+
method: "*";
|
|
116
|
+
}> & {
|
|
117
|
+
/**
|
|
118
|
+
* Method
|
|
119
|
+
*
|
|
120
|
+
* The request method
|
|
121
|
+
*/
|
|
122
|
+
method: string;
|
|
123
|
+
/**
|
|
124
|
+
* Path
|
|
125
|
+
*
|
|
126
|
+
* The path of the endpoint
|
|
127
|
+
*/
|
|
128
|
+
path: string;
|
|
129
|
+
/**
|
|
130
|
+
* Body
|
|
131
|
+
*
|
|
132
|
+
* The body object will be the parsed JSON from the request and validated
|
|
133
|
+
* against the body schema if it exists
|
|
134
|
+
*/
|
|
135
|
+
body: InferMiddlewareBody<Options>;
|
|
136
|
+
/**
|
|
137
|
+
* Query
|
|
138
|
+
*
|
|
139
|
+
* The query object will be the parsed query string from the request
|
|
140
|
+
* and validated against the query schema if it exists
|
|
141
|
+
*/
|
|
142
|
+
query: InferMiddlewareQuery<Options>;
|
|
143
|
+
/**
|
|
144
|
+
* Params
|
|
145
|
+
*
|
|
146
|
+
* If the path is `/user/:id` and the request is `/user/1` then the
|
|
147
|
+
* params will
|
|
148
|
+
* be `{ id: "1" }` and if the path includes a wildcard like `/user/*`
|
|
149
|
+
* then the
|
|
150
|
+
* params will be `{ _: "1" }` where `_` is the wildcard key. If the
|
|
151
|
+
* wildcard
|
|
152
|
+
* is named like `/user/**:name` then the params will be `{ name: string }`
|
|
153
|
+
*/
|
|
154
|
+
params: string;
|
|
155
|
+
/**
|
|
156
|
+
* Request object
|
|
157
|
+
*
|
|
158
|
+
* If `requireRequest` is set to true in the endpoint options this will be
|
|
159
|
+
* required
|
|
160
|
+
*/
|
|
161
|
+
request: InferRequest<Options>;
|
|
162
|
+
/**
|
|
163
|
+
* Headers
|
|
164
|
+
*
|
|
165
|
+
* If `requireHeaders` is set to true in the endpoint options this will be
|
|
166
|
+
* required
|
|
167
|
+
*/
|
|
168
|
+
headers: InferHeaders<Options>;
|
|
169
|
+
/**
|
|
170
|
+
* Set header
|
|
171
|
+
*
|
|
172
|
+
* If it's called outside of a request it will just be ignored.
|
|
173
|
+
*/
|
|
174
|
+
setHeader: (key: string, value: string) => void;
|
|
175
|
+
/**
|
|
176
|
+
* Get header
|
|
177
|
+
*
|
|
178
|
+
* If it's called outside of a request it will just return null
|
|
179
|
+
*
|
|
180
|
+
* @param key - The key of the header
|
|
181
|
+
* @returns
|
|
182
|
+
*/
|
|
183
|
+
getHeader: (key: string) => string | null;
|
|
184
|
+
/**
|
|
185
|
+
* JSON
|
|
186
|
+
*
|
|
187
|
+
* a helper function to create a JSON response with
|
|
188
|
+
* the correct headers
|
|
189
|
+
* and status code. If `asResponse` is set to true in
|
|
190
|
+
* the context then
|
|
191
|
+
* it will return a Response object instead of the
|
|
192
|
+
* JSON object.
|
|
193
|
+
*
|
|
194
|
+
* @param json - The JSON object to return
|
|
195
|
+
* @param routerResponse - The response object to
|
|
196
|
+
* return if `asResponse` is
|
|
197
|
+
* true in the context this will take precedence
|
|
198
|
+
*/
|
|
199
|
+
json: <R extends Record<string, any> | null>(json: R, routerResponse?: {
|
|
200
|
+
status?: number;
|
|
201
|
+
headers?: Record<string, string>;
|
|
202
|
+
response?: Response;
|
|
203
|
+
} | Response) => Promise<R>;
|
|
204
|
+
/**
|
|
205
|
+
* Middleware context
|
|
206
|
+
*/
|
|
207
|
+
context: Prettify<Context>;
|
|
208
|
+
};
|
|
209
|
+
declare function createMiddleware<Options extends MiddlewareOptions, R>(options: Options, handler: (context: MiddlewareContext<Options>) => Promise<R>): <InputCtx extends MiddlewareInputContext<Options>>(inputContext: InputCtx) => Promise<R>;
|
|
210
|
+
declare function createMiddleware<Options extends MiddlewareOptions, R>(handler: (context: MiddlewareContext<Options>) => Promise<R>): <InputCtx extends MiddlewareInputContext<Options>>(inputContext: InputCtx) => Promise<R>;
|
|
211
|
+
declare namespace createMiddleware {
|
|
212
|
+
var create: <E extends {
|
|
213
|
+
use?: Middleware[];
|
|
214
|
+
}>(opts?: E) => {
|
|
215
|
+
<Options extends MiddlewareOptions, R>(options: Options, handler: (ctx: MiddlewareContext<Options, InferUse<E["use"]>>) => Promise<R>): (inputContext: MiddlewareInputContext<Options>) => Promise<R>;
|
|
216
|
+
<Options extends MiddlewareOptions, R_1>(handler: (ctx: MiddlewareContext<Options, InferUse<E["use"]>>) => Promise<R_1>): (inputContext: MiddlewareInputContext<Options>) => Promise<R_1>;
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
type MiddlewareInputContext<Options extends MiddlewareOptions> = InferBodyInput<Options> & InferQueryInput<Options> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
220
|
+
asResponse?: boolean;
|
|
221
|
+
returnHeaders?: boolean;
|
|
222
|
+
use?: Middleware[];
|
|
223
|
+
};
|
|
224
|
+
type Middleware<Options extends MiddlewareOptions = MiddlewareOptions, Handler extends (inputCtx: any) => Promise<any> = any> = Handler & {
|
|
225
|
+
options: Options;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
type CookiePrefixOptions = "host" | "secure";
|
|
229
|
+
type CookieOptions = {
|
|
230
|
+
/**
|
|
231
|
+
* Domain of the cookie
|
|
232
|
+
*
|
|
233
|
+
* The Domain attribute specifies which server can receive a cookie. If specified, cookies are
|
|
234
|
+
* available on the specified server and its subdomains. If the it is not
|
|
235
|
+
* specified, the cookies are available on the server that sets it but not on
|
|
236
|
+
* its subdomains.
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* `domain: "example.com"`
|
|
240
|
+
*/
|
|
241
|
+
domain?: string;
|
|
242
|
+
/**
|
|
243
|
+
* A lifetime of a cookie. Permanent cookies are deleted after the date specified in the
|
|
244
|
+
* Expires attribute:
|
|
245
|
+
*
|
|
246
|
+
* Expires has been available for longer than Max-Age, however Max-Age is less error-prone, and
|
|
247
|
+
* takes precedence when both are set. The rationale behind this is that when you set an
|
|
248
|
+
* Expires date and time, they're relative to the client the cookie is being set on. If the
|
|
249
|
+
* server is set to a different time, this could cause errors
|
|
250
|
+
*/
|
|
251
|
+
expires?: Date;
|
|
252
|
+
/**
|
|
253
|
+
* Forbids JavaScript from accessing the cookie, for example, through the Document.cookie
|
|
254
|
+
* property. Note that a cookie that has been created with HttpOnly will still be sent with
|
|
255
|
+
* JavaScript-initiated requests, for example, when calling XMLHttpRequest.send() or fetch().
|
|
256
|
+
* This mitigates attacks against cross-site scripting
|
|
257
|
+
*/
|
|
258
|
+
httpOnly?: boolean;
|
|
259
|
+
/**
|
|
260
|
+
* Indicates the number of seconds until the cookie expires. A zero or negative number will
|
|
261
|
+
* expire the cookie immediately. If both Expires and Max-Age are set, Max-Age has precedence.
|
|
262
|
+
*
|
|
263
|
+
* @example 604800 - 7 days
|
|
264
|
+
*/
|
|
265
|
+
maxAge?: number;
|
|
266
|
+
/**
|
|
267
|
+
* Indicates the path that must exist in the requested URL for the browser to send the Cookie
|
|
268
|
+
* header.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* "/docs"
|
|
272
|
+
* // -> the request paths /docs, /docs/, /docs/Web/, and /docs/Web/HTTP will all match. the request paths /, /fr/docs will not match.
|
|
273
|
+
*/
|
|
274
|
+
path?: string;
|
|
275
|
+
/**
|
|
276
|
+
* Indicates that the cookie is sent to the server only when a request is made with the https:
|
|
277
|
+
* scheme (except on localhost), and therefore, is more resistant to man-in-the-middle attacks.
|
|
278
|
+
*/
|
|
279
|
+
secure?: boolean;
|
|
280
|
+
/**
|
|
281
|
+
* Controls whether or not a cookie is sent with cross-site requests, providing some protection
|
|
282
|
+
* against cross-site request forgery attacks (CSRF).
|
|
283
|
+
*
|
|
284
|
+
* Strict - Means that the browser sends the cookie only for same-site requests, that is,
|
|
285
|
+
* requests originating from the same site that set the cookie. If a request originates from a
|
|
286
|
+
* different domain or scheme (even with the same domain), no cookies with the SameSite=Strict
|
|
287
|
+
* attribute are sent.
|
|
288
|
+
*
|
|
289
|
+
* Lax - Means that the cookie is not sent on cross-site requests, such as on requests to load
|
|
290
|
+
* images or frames, but is sent when a user is navigating to the origin site from an external
|
|
291
|
+
* site (for example, when following a link). This is the default behavior if the SameSite
|
|
292
|
+
* attribute is not specified.
|
|
293
|
+
*
|
|
294
|
+
* None - Means that the browser sends the cookie with both cross-site and same-site requests.
|
|
295
|
+
* The Secure attribute must also be set when setting this value.
|
|
296
|
+
*/
|
|
297
|
+
sameSite?: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
|
|
298
|
+
/**
|
|
299
|
+
* Indicates that the cookie should be stored using partitioned storage. Note that if this is
|
|
300
|
+
* set, the Secure directive must also be set.
|
|
301
|
+
*
|
|
302
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/Privacy/Privacy_sandbox/Partitioned_cookies
|
|
303
|
+
*/
|
|
304
|
+
partitioned?: boolean;
|
|
305
|
+
/**
|
|
306
|
+
* Cooke Prefix
|
|
307
|
+
*
|
|
308
|
+
* - secure: `__Secure-` -> `__Secure-cookie-name`
|
|
309
|
+
* - host: `__Host-` -> `__Host-cookie-name`
|
|
310
|
+
*
|
|
311
|
+
* `secure` must be set to true to use prefixes
|
|
312
|
+
*/
|
|
313
|
+
prefix?: CookiePrefixOptions;
|
|
314
|
+
};
|
|
315
|
+
declare const getCookieKey: (key: string, prefix?: CookiePrefixOptions) => string | undefined;
|
|
316
|
+
/**
|
|
317
|
+
* Parse an HTTP Cookie header string and returning an object of all cookie
|
|
318
|
+
* name-value pairs.
|
|
319
|
+
*
|
|
320
|
+
* Inspired by https://github.com/unjs/cookie-es/blob/main/src/cookie/parse.ts
|
|
321
|
+
*
|
|
322
|
+
* @param str the string representing a `Cookie` header value
|
|
323
|
+
*/
|
|
324
|
+
declare function parseCookies(str: string): Map<string, string>;
|
|
325
|
+
declare const serializeCookie: (key: string, value: string, opt?: CookieOptions) => string;
|
|
326
|
+
declare const serializeSignedCookie: (key: string, value: string, secret: string, opt?: CookieOptions) => Promise<string>;
|
|
327
|
+
|
|
328
|
+
/** The Standard Schema interface. */
|
|
329
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
330
|
+
/** The Standard Schema properties. */
|
|
331
|
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
332
|
+
}
|
|
333
|
+
declare namespace StandardSchemaV1 {
|
|
334
|
+
/** The Standard Schema properties interface. */
|
|
335
|
+
interface Props<Input = unknown, Output = Input> {
|
|
336
|
+
/** The version number of the standard. */
|
|
337
|
+
readonly version: 1;
|
|
338
|
+
/** The vendor name of the schema library. */
|
|
339
|
+
readonly vendor: string;
|
|
340
|
+
/** Validates unknown input values. */
|
|
341
|
+
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
|
|
342
|
+
/** Inferred types associated with the schema. */
|
|
343
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
344
|
+
}
|
|
345
|
+
/** The result interface of the validate function. */
|
|
346
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
347
|
+
/** The result interface if validation succeeds. */
|
|
348
|
+
interface SuccessResult<Output> {
|
|
349
|
+
/** The typed output value. */
|
|
350
|
+
readonly value: Output;
|
|
351
|
+
/** The non-existent issues. */
|
|
352
|
+
readonly issues?: undefined;
|
|
353
|
+
}
|
|
354
|
+
/** The result interface if validation fails. */
|
|
355
|
+
interface FailureResult {
|
|
356
|
+
/** The issues of failed validation. */
|
|
357
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
358
|
+
}
|
|
359
|
+
/** The issue interface of the failure output. */
|
|
360
|
+
interface Issue {
|
|
361
|
+
/** The error message of the issue. */
|
|
362
|
+
readonly message: string;
|
|
363
|
+
/** The path of the issue, if any. */
|
|
364
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
365
|
+
}
|
|
366
|
+
/** The path segment interface of the issue. */
|
|
367
|
+
interface PathSegment {
|
|
368
|
+
/** The key representing a path segment. */
|
|
369
|
+
readonly key: PropertyKey;
|
|
370
|
+
}
|
|
371
|
+
/** The Standard Schema types interface. */
|
|
372
|
+
interface Types<Input = unknown, Output = Input> {
|
|
373
|
+
/** The input type of the schema. */
|
|
374
|
+
readonly input: Input;
|
|
375
|
+
/** The output type of the schema. */
|
|
376
|
+
readonly output: Output;
|
|
377
|
+
}
|
|
378
|
+
/** Infers the input type of a Standard Schema. */
|
|
379
|
+
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
380
|
+
/** Infers the output type of a Standard Schema. */
|
|
381
|
+
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
type HTTPMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
|
|
385
|
+
type Method = HTTPMethod | "*";
|
|
386
|
+
type InferBodyInput<Options extends EndpointOptions | MiddlewareOptions, Body = Options["metadata"] extends {
|
|
387
|
+
$Infer: {
|
|
388
|
+
body: infer B;
|
|
389
|
+
};
|
|
390
|
+
} ? B : Options["body"] extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Options["body"]> : undefined> = undefined extends Body ? {
|
|
391
|
+
body?: Body;
|
|
392
|
+
} : {
|
|
393
|
+
body: Body;
|
|
394
|
+
};
|
|
395
|
+
type InferBody<Options extends EndpointOptions | MiddlewareOptions> = Options["metadata"] extends {
|
|
396
|
+
$Infer: {
|
|
397
|
+
body: infer Body;
|
|
398
|
+
};
|
|
399
|
+
} ? Body : Options["body"] extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Options["body"]> : any;
|
|
400
|
+
type InferQueryInput<Options extends EndpointOptions | MiddlewareOptions, Query = Options["metadata"] extends {
|
|
401
|
+
$Infer: {
|
|
402
|
+
query: infer Query;
|
|
403
|
+
};
|
|
404
|
+
} ? Query : Options["query"] extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> = undefined extends Query ? {
|
|
405
|
+
query?: Query;
|
|
406
|
+
} : {
|
|
407
|
+
query: Query;
|
|
408
|
+
};
|
|
409
|
+
type InferQuery<Options extends EndpointOptions | MiddlewareOptions> = Options["metadata"] extends {
|
|
410
|
+
$Infer: {
|
|
411
|
+
query: infer Query;
|
|
412
|
+
};
|
|
413
|
+
} ? Query : Options["query"] extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Options["query"]> : Record<string, any> | undefined;
|
|
414
|
+
type InferMethod<Options extends EndpointOptions> = Options["method"] extends Array<Method> ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"];
|
|
415
|
+
type InferInputMethod<Options extends EndpointOptions, Method = Options["method"] extends Array<any> ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> = undefined extends Method ? {
|
|
416
|
+
method?: Method;
|
|
417
|
+
} : {
|
|
418
|
+
method: Method;
|
|
419
|
+
};
|
|
420
|
+
type InferParam<Path extends string> = IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? Record<string, any> | undefined : Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
|
|
421
|
+
type InferParamInput<Path extends string> = IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? {
|
|
422
|
+
params?: Record<string, any>;
|
|
423
|
+
} : {
|
|
424
|
+
params: Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
|
|
425
|
+
};
|
|
426
|
+
type InferRequest<Option extends EndpointOptions | MiddlewareOptions> = Option["requireRequest"] extends true ? Request : Request | undefined;
|
|
427
|
+
type InferRequestInput<Option extends EndpointOptions | MiddlewareOptions> = Option["requireRequest"] extends true ? {
|
|
428
|
+
request: Request;
|
|
429
|
+
} : {
|
|
430
|
+
request?: Request;
|
|
431
|
+
};
|
|
432
|
+
type InferHeaders<Option extends EndpointOptions | MiddlewareOptions> = Option["requireHeaders"] extends true ? Headers : Headers | undefined;
|
|
433
|
+
type InferHeadersInput<Option extends EndpointOptions | MiddlewareOptions> = Option["requireHeaders"] extends true ? {
|
|
434
|
+
headers: HeadersInit;
|
|
435
|
+
} : {
|
|
436
|
+
headers?: HeadersInit;
|
|
437
|
+
};
|
|
438
|
+
type InferUse<Opts extends EndpointOptions["use"]> = Opts extends Middleware[] ? UnionToIntersection<Awaited<ReturnType<Opts[number]>>> : {};
|
|
439
|
+
type InferMiddlewareBody<Options extends MiddlewareOptions> = Options["body"] extends StandardSchemaV1<infer T> ? T : any;
|
|
440
|
+
type InferMiddlewareQuery<Options extends MiddlewareOptions> = Options["query"] extends StandardSchemaV1<infer T> ? T : Record<string, any> | undefined;
|
|
441
|
+
type InputContext<Path extends string, Options extends EndpointOptions> = InferBodyInput<Options> & InferInputMethod<Options> & InferQueryInput<Options> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
442
|
+
asResponse?: boolean;
|
|
443
|
+
returnHeaders?: boolean;
|
|
444
|
+
use?: Middleware[];
|
|
445
|
+
path?: string;
|
|
446
|
+
};
|
|
447
|
+
declare const createInternalContext: (context: InputContext<any, any>, { options, path, }: {
|
|
448
|
+
options: EndpointOptions;
|
|
449
|
+
path: string;
|
|
450
|
+
}) => Promise<{
|
|
451
|
+
body: any;
|
|
452
|
+
query: any;
|
|
453
|
+
path: string;
|
|
454
|
+
context: {};
|
|
455
|
+
returned: any;
|
|
456
|
+
headers: HeadersInit | undefined;
|
|
457
|
+
request: Request | undefined;
|
|
458
|
+
params: Record<string, any> | undefined;
|
|
459
|
+
method: any;
|
|
460
|
+
setHeader: (key: string, value: string) => void;
|
|
461
|
+
getHeader: (key: string) => string | null;
|
|
462
|
+
getCookie: (key: string, prefix?: CookiePrefixOptions) => string | null;
|
|
463
|
+
getSignedCookie: (key: string, secret: string, prefix?: CookiePrefixOptions) => Promise<string | false | null>;
|
|
464
|
+
setCookie: (key: string, value: string, options?: CookieOptions) => string;
|
|
465
|
+
setSignedCookie: (key: string, value: string, secret: string, options?: CookieOptions) => Promise<string>;
|
|
466
|
+
redirect: (url: string) => {
|
|
467
|
+
status: keyof typeof _statusCode | Status;
|
|
468
|
+
body: ({
|
|
469
|
+
message?: string;
|
|
470
|
+
code?: string;
|
|
471
|
+
cause?: unknown;
|
|
472
|
+
} & Record<string, any>) | undefined;
|
|
473
|
+
headers: HeadersInit;
|
|
474
|
+
statusCode: number;
|
|
475
|
+
name: string;
|
|
476
|
+
message: string;
|
|
477
|
+
stack?: string;
|
|
478
|
+
cause?: unknown;
|
|
479
|
+
} & {
|
|
480
|
+
errorStack: string | undefined;
|
|
481
|
+
};
|
|
482
|
+
error: (status: keyof typeof _statusCode | Status, body?: {
|
|
483
|
+
message?: string;
|
|
484
|
+
code?: string;
|
|
485
|
+
} | undefined, headers?: HeadersInit) => {
|
|
486
|
+
status: keyof typeof _statusCode | Status;
|
|
487
|
+
body: ({
|
|
488
|
+
message?: string;
|
|
489
|
+
code?: string;
|
|
490
|
+
cause?: unknown;
|
|
491
|
+
} & Record<string, any>) | undefined;
|
|
492
|
+
headers: HeadersInit;
|
|
493
|
+
statusCode: number;
|
|
494
|
+
name: string;
|
|
495
|
+
message: string;
|
|
496
|
+
stack?: string;
|
|
497
|
+
cause?: unknown;
|
|
498
|
+
} & {
|
|
499
|
+
errorStack: string | undefined;
|
|
500
|
+
};
|
|
501
|
+
json: (json: Record<string, any>, routerResponse?: {
|
|
502
|
+
status?: number;
|
|
503
|
+
headers?: Record<string, string>;
|
|
504
|
+
response?: Response;
|
|
505
|
+
body?: Record<string, any>;
|
|
506
|
+
} | Response) => Record<string, any>;
|
|
507
|
+
responseHeaders: Headers;
|
|
508
|
+
asResponse?: boolean;
|
|
509
|
+
returnHeaders?: boolean;
|
|
510
|
+
use?: Middleware[];
|
|
511
|
+
} | {
|
|
512
|
+
body: any;
|
|
513
|
+
query: any;
|
|
514
|
+
path: string;
|
|
515
|
+
context: {};
|
|
516
|
+
returned: any;
|
|
517
|
+
headers: HeadersInit | undefined;
|
|
518
|
+
request: Request | undefined;
|
|
519
|
+
params: Record<string, any> | undefined;
|
|
520
|
+
method: any;
|
|
521
|
+
setHeader: (key: string, value: string) => void;
|
|
522
|
+
getHeader: (key: string) => string | null;
|
|
523
|
+
getCookie: (key: string, prefix?: CookiePrefixOptions) => string | null;
|
|
524
|
+
getSignedCookie: (key: string, secret: string, prefix?: CookiePrefixOptions) => Promise<string | false | null>;
|
|
525
|
+
setCookie: (key: string, value: string, options?: CookieOptions) => string;
|
|
526
|
+
setSignedCookie: (key: string, value: string, secret: string, options?: CookieOptions) => Promise<string>;
|
|
527
|
+
redirect: (url: string) => {
|
|
528
|
+
status: keyof typeof _statusCode | Status;
|
|
529
|
+
body: ({
|
|
530
|
+
message?: string;
|
|
531
|
+
code?: string;
|
|
532
|
+
cause?: unknown;
|
|
533
|
+
} & Record<string, any>) | undefined;
|
|
534
|
+
headers: HeadersInit;
|
|
535
|
+
statusCode: number;
|
|
536
|
+
name: string;
|
|
537
|
+
message: string;
|
|
538
|
+
stack?: string;
|
|
539
|
+
cause?: unknown;
|
|
540
|
+
} & {
|
|
541
|
+
errorStack: string | undefined;
|
|
542
|
+
};
|
|
543
|
+
error: (status: keyof typeof _statusCode | Status, body?: {
|
|
544
|
+
message?: string;
|
|
545
|
+
code?: string;
|
|
546
|
+
} | undefined, headers?: HeadersInit) => {
|
|
547
|
+
status: keyof typeof _statusCode | Status;
|
|
548
|
+
body: ({
|
|
549
|
+
message?: string;
|
|
550
|
+
code?: string;
|
|
551
|
+
cause?: unknown;
|
|
552
|
+
} & Record<string, any>) | undefined;
|
|
553
|
+
headers: HeadersInit;
|
|
554
|
+
statusCode: number;
|
|
555
|
+
name: string;
|
|
556
|
+
message: string;
|
|
557
|
+
stack?: string;
|
|
558
|
+
cause?: unknown;
|
|
559
|
+
} & {
|
|
560
|
+
errorStack: string | undefined;
|
|
561
|
+
};
|
|
562
|
+
json: (json: Record<string, any>, routerResponse?: {
|
|
563
|
+
status?: number;
|
|
564
|
+
headers?: Record<string, string>;
|
|
565
|
+
response?: Response;
|
|
566
|
+
body?: Record<string, any>;
|
|
567
|
+
} | Response) => Record<string, any>;
|
|
568
|
+
responseHeaders: Headers;
|
|
569
|
+
asResponse?: boolean;
|
|
570
|
+
returnHeaders?: boolean;
|
|
571
|
+
use?: Middleware[];
|
|
572
|
+
} | {
|
|
573
|
+
body: any;
|
|
574
|
+
query: any;
|
|
575
|
+
path: string;
|
|
576
|
+
context: {};
|
|
577
|
+
returned: any;
|
|
578
|
+
headers: HeadersInit | undefined;
|
|
579
|
+
request: Request | undefined;
|
|
580
|
+
params: Record<string, any> | undefined;
|
|
581
|
+
method: any;
|
|
582
|
+
setHeader: (key: string, value: string) => void;
|
|
583
|
+
getHeader: (key: string) => string | null;
|
|
584
|
+
getCookie: (key: string, prefix?: CookiePrefixOptions) => string | null;
|
|
585
|
+
getSignedCookie: (key: string, secret: string, prefix?: CookiePrefixOptions) => Promise<string | false | null>;
|
|
586
|
+
setCookie: (key: string, value: string, options?: CookieOptions) => string;
|
|
587
|
+
setSignedCookie: (key: string, value: string, secret: string, options?: CookieOptions) => Promise<string>;
|
|
588
|
+
redirect: (url: string) => {
|
|
589
|
+
status: keyof typeof _statusCode | Status;
|
|
590
|
+
body: ({
|
|
591
|
+
message?: string;
|
|
592
|
+
code?: string;
|
|
593
|
+
cause?: unknown;
|
|
594
|
+
} & Record<string, any>) | undefined;
|
|
595
|
+
headers: HeadersInit;
|
|
596
|
+
statusCode: number;
|
|
597
|
+
name: string;
|
|
598
|
+
message: string;
|
|
599
|
+
stack?: string;
|
|
600
|
+
cause?: unknown;
|
|
601
|
+
} & {
|
|
602
|
+
errorStack: string | undefined;
|
|
603
|
+
};
|
|
604
|
+
error: (status: keyof typeof _statusCode | Status, body?: {
|
|
605
|
+
message?: string;
|
|
606
|
+
code?: string;
|
|
607
|
+
} | undefined, headers?: HeadersInit) => {
|
|
608
|
+
status: keyof typeof _statusCode | Status;
|
|
609
|
+
body: ({
|
|
610
|
+
message?: string;
|
|
611
|
+
code?: string;
|
|
612
|
+
cause?: unknown;
|
|
613
|
+
} & Record<string, any>) | undefined;
|
|
614
|
+
headers: HeadersInit;
|
|
615
|
+
statusCode: number;
|
|
616
|
+
name: string;
|
|
617
|
+
message: string;
|
|
618
|
+
stack?: string;
|
|
619
|
+
cause?: unknown;
|
|
620
|
+
} & {
|
|
621
|
+
errorStack: string | undefined;
|
|
622
|
+
};
|
|
623
|
+
json: (json: Record<string, any>, routerResponse?: {
|
|
624
|
+
status?: number;
|
|
625
|
+
headers?: Record<string, string>;
|
|
626
|
+
response?: Response;
|
|
627
|
+
body?: Record<string, any>;
|
|
628
|
+
} | Response) => Record<string, any>;
|
|
629
|
+
responseHeaders: Headers;
|
|
630
|
+
asResponse?: boolean;
|
|
631
|
+
returnHeaders?: boolean;
|
|
632
|
+
use?: Middleware[];
|
|
633
|
+
} | {
|
|
634
|
+
body: any;
|
|
635
|
+
query: any;
|
|
636
|
+
path: string;
|
|
637
|
+
context: {};
|
|
638
|
+
returned: any;
|
|
639
|
+
headers: HeadersInit | undefined;
|
|
640
|
+
request: Request | undefined;
|
|
641
|
+
params: Record<string, any> | undefined;
|
|
642
|
+
method: any;
|
|
643
|
+
setHeader: (key: string, value: string) => void;
|
|
644
|
+
getHeader: (key: string) => string | null;
|
|
645
|
+
getCookie: (key: string, prefix?: CookiePrefixOptions) => string | null;
|
|
646
|
+
getSignedCookie: (key: string, secret: string, prefix?: CookiePrefixOptions) => Promise<string | false | null>;
|
|
647
|
+
setCookie: (key: string, value: string, options?: CookieOptions) => string;
|
|
648
|
+
setSignedCookie: (key: string, value: string, secret: string, options?: CookieOptions) => Promise<string>;
|
|
649
|
+
redirect: (url: string) => {
|
|
650
|
+
status: keyof typeof _statusCode | Status;
|
|
651
|
+
body: ({
|
|
652
|
+
message?: string;
|
|
653
|
+
code?: string;
|
|
654
|
+
cause?: unknown;
|
|
655
|
+
} & Record<string, any>) | undefined;
|
|
656
|
+
headers: HeadersInit;
|
|
657
|
+
statusCode: number;
|
|
658
|
+
name: string;
|
|
659
|
+
message: string;
|
|
660
|
+
stack?: string;
|
|
661
|
+
cause?: unknown;
|
|
662
|
+
} & {
|
|
663
|
+
errorStack: string | undefined;
|
|
664
|
+
};
|
|
665
|
+
error: (status: keyof typeof _statusCode | Status, body?: {
|
|
666
|
+
message?: string;
|
|
667
|
+
code?: string;
|
|
668
|
+
} | undefined, headers?: HeadersInit) => {
|
|
669
|
+
status: keyof typeof _statusCode | Status;
|
|
670
|
+
body: ({
|
|
671
|
+
message?: string;
|
|
672
|
+
code?: string;
|
|
673
|
+
cause?: unknown;
|
|
674
|
+
} & Record<string, any>) | undefined;
|
|
675
|
+
headers: HeadersInit;
|
|
676
|
+
statusCode: number;
|
|
677
|
+
name: string;
|
|
678
|
+
message: string;
|
|
679
|
+
stack?: string;
|
|
680
|
+
cause?: unknown;
|
|
681
|
+
} & {
|
|
682
|
+
errorStack: string | undefined;
|
|
683
|
+
};
|
|
684
|
+
json: (json: Record<string, any>, routerResponse?: {
|
|
685
|
+
status?: number;
|
|
686
|
+
headers?: Record<string, string>;
|
|
687
|
+
response?: Response;
|
|
688
|
+
body?: Record<string, any>;
|
|
689
|
+
} | Response) => Record<string, any>;
|
|
690
|
+
responseHeaders: Headers;
|
|
691
|
+
asResponse?: boolean;
|
|
692
|
+
returnHeaders?: boolean;
|
|
693
|
+
use?: Middleware[];
|
|
694
|
+
}>;
|
|
695
|
+
|
|
696
|
+
type OpenAPISchemaType = "string" | "number" | "integer" | "boolean" | "array" | "object";
|
|
697
|
+
interface OpenAPIParameter {
|
|
698
|
+
in: "query" | "path" | "header" | "cookie";
|
|
699
|
+
name?: string;
|
|
700
|
+
description?: string;
|
|
701
|
+
required?: boolean;
|
|
702
|
+
schema?: {
|
|
703
|
+
type: OpenAPISchemaType;
|
|
704
|
+
format?: string;
|
|
705
|
+
items?: {
|
|
706
|
+
type: OpenAPISchemaType;
|
|
707
|
+
};
|
|
708
|
+
enum?: string[];
|
|
709
|
+
minLength?: number;
|
|
710
|
+
description?: string;
|
|
711
|
+
default?: string;
|
|
712
|
+
example?: string;
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
interface Path {
|
|
716
|
+
get?: {
|
|
717
|
+
tags?: string[];
|
|
718
|
+
operationId?: string;
|
|
719
|
+
description?: string;
|
|
720
|
+
security?: [{
|
|
721
|
+
bearerAuth: string[];
|
|
722
|
+
}];
|
|
723
|
+
parameters?: OpenAPIParameter[];
|
|
724
|
+
responses?: {
|
|
725
|
+
[key in string]: {
|
|
726
|
+
description?: string;
|
|
727
|
+
content: {
|
|
728
|
+
"application/json": {
|
|
729
|
+
schema: {
|
|
730
|
+
type?: OpenAPISchemaType;
|
|
731
|
+
properties?: Record<string, any>;
|
|
732
|
+
required?: string[];
|
|
733
|
+
$ref?: string;
|
|
734
|
+
};
|
|
735
|
+
};
|
|
736
|
+
};
|
|
737
|
+
};
|
|
738
|
+
};
|
|
739
|
+
};
|
|
740
|
+
post?: {
|
|
741
|
+
tags?: string[];
|
|
742
|
+
operationId?: string;
|
|
743
|
+
description?: string;
|
|
744
|
+
security?: [{
|
|
745
|
+
bearerAuth: string[];
|
|
746
|
+
}];
|
|
747
|
+
parameters?: OpenAPIParameter[];
|
|
748
|
+
requestBody?: {
|
|
749
|
+
content: {
|
|
750
|
+
"application/json": {
|
|
751
|
+
schema: {
|
|
752
|
+
type?: OpenAPISchemaType;
|
|
753
|
+
properties?: Record<string, any>;
|
|
754
|
+
required?: string[];
|
|
755
|
+
$ref?: string;
|
|
756
|
+
};
|
|
757
|
+
};
|
|
758
|
+
};
|
|
759
|
+
};
|
|
760
|
+
responses?: {
|
|
761
|
+
[key in string]: {
|
|
762
|
+
description?: string;
|
|
763
|
+
content: {
|
|
764
|
+
"application/json": {
|
|
765
|
+
schema: {
|
|
766
|
+
type?: OpenAPISchemaType;
|
|
767
|
+
properties?: Record<string, any>;
|
|
768
|
+
required?: string[];
|
|
769
|
+
$ref?: string;
|
|
770
|
+
};
|
|
771
|
+
};
|
|
772
|
+
};
|
|
773
|
+
};
|
|
774
|
+
};
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
declare function generator(endpoints: Record<string, Endpoint>, config?: {
|
|
778
|
+
url: string;
|
|
779
|
+
}): Promise<{
|
|
780
|
+
openapi: string;
|
|
781
|
+
info: {
|
|
782
|
+
title: string;
|
|
783
|
+
description: string;
|
|
784
|
+
version: string;
|
|
785
|
+
};
|
|
786
|
+
components: {
|
|
787
|
+
schemas: {};
|
|
788
|
+
};
|
|
789
|
+
security: {
|
|
790
|
+
apiKeyCookie: never[];
|
|
791
|
+
}[];
|
|
792
|
+
servers: {
|
|
793
|
+
url: string | undefined;
|
|
794
|
+
}[];
|
|
795
|
+
tags: {
|
|
796
|
+
name: string;
|
|
797
|
+
description: string;
|
|
798
|
+
}[];
|
|
799
|
+
paths: Record<string, Path>;
|
|
800
|
+
}>;
|
|
801
|
+
declare const getHTML: (apiReference: Record<string, any>, config?: {
|
|
802
|
+
logo?: string;
|
|
803
|
+
theme?: string;
|
|
804
|
+
title?: string;
|
|
805
|
+
description?: string;
|
|
806
|
+
}) => string;
|
|
807
|
+
|
|
808
|
+
interface EndpointOptions {
|
|
809
|
+
/**
|
|
810
|
+
* Request Method
|
|
811
|
+
*/
|
|
812
|
+
method: Method | Method[];
|
|
813
|
+
/**
|
|
814
|
+
* Body Schema
|
|
815
|
+
*/
|
|
816
|
+
body?: StandardSchemaV1;
|
|
817
|
+
/**
|
|
818
|
+
* Query Schema
|
|
819
|
+
*/
|
|
820
|
+
query?: StandardSchemaV1;
|
|
821
|
+
/**
|
|
822
|
+
* Error Schema
|
|
823
|
+
*/
|
|
824
|
+
error?: StandardSchemaV1;
|
|
825
|
+
/**
|
|
826
|
+
* If true headers will be required to be passed in the context
|
|
827
|
+
*/
|
|
828
|
+
requireHeaders?: boolean;
|
|
829
|
+
/**
|
|
830
|
+
* If true request object will be required
|
|
831
|
+
*/
|
|
832
|
+
requireRequest?: boolean;
|
|
833
|
+
/**
|
|
834
|
+
* Clone the request object from the router
|
|
835
|
+
*/
|
|
836
|
+
cloneRequest?: boolean;
|
|
837
|
+
/**
|
|
838
|
+
* If true the body will be undefined
|
|
839
|
+
*/
|
|
840
|
+
disableBody?: boolean;
|
|
841
|
+
/**
|
|
842
|
+
* Endpoint metadata
|
|
843
|
+
*/
|
|
844
|
+
metadata?: {
|
|
845
|
+
/**
|
|
846
|
+
* Open API definition
|
|
847
|
+
*/
|
|
848
|
+
openapi?: {
|
|
849
|
+
summary?: string;
|
|
850
|
+
description?: string;
|
|
851
|
+
tags?: string[];
|
|
852
|
+
operationId?: string;
|
|
853
|
+
parameters?: OpenAPIParameter[];
|
|
854
|
+
requestBody?: {
|
|
855
|
+
content: {
|
|
856
|
+
"application/json": {
|
|
857
|
+
schema: {
|
|
858
|
+
type?: OpenAPISchemaType;
|
|
859
|
+
properties?: Record<string, any>;
|
|
860
|
+
required?: string[];
|
|
861
|
+
$ref?: string;
|
|
862
|
+
};
|
|
863
|
+
};
|
|
864
|
+
};
|
|
865
|
+
};
|
|
866
|
+
responses?: {
|
|
867
|
+
[status: string]: {
|
|
868
|
+
description: string;
|
|
869
|
+
content?: {
|
|
870
|
+
"application/json"?: {
|
|
871
|
+
schema: {
|
|
872
|
+
type?: OpenAPISchemaType;
|
|
873
|
+
properties?: Record<string, any>;
|
|
874
|
+
required?: string[];
|
|
875
|
+
$ref?: string;
|
|
876
|
+
};
|
|
877
|
+
};
|
|
878
|
+
"text/plain"?: {
|
|
879
|
+
schema?: {
|
|
880
|
+
type?: OpenAPISchemaType;
|
|
881
|
+
properties?: Record<string, any>;
|
|
882
|
+
required?: string[];
|
|
883
|
+
$ref?: string;
|
|
884
|
+
};
|
|
885
|
+
};
|
|
886
|
+
"text/html"?: {
|
|
887
|
+
schema?: {
|
|
888
|
+
type?: OpenAPISchemaType;
|
|
889
|
+
properties?: Record<string, any>;
|
|
890
|
+
required?: string[];
|
|
891
|
+
$ref?: string;
|
|
892
|
+
};
|
|
893
|
+
};
|
|
894
|
+
};
|
|
895
|
+
};
|
|
896
|
+
};
|
|
897
|
+
};
|
|
898
|
+
/**
|
|
899
|
+
* Infer body and query type from ts interface
|
|
900
|
+
*
|
|
901
|
+
* useful for generic and dynamic types
|
|
902
|
+
*
|
|
903
|
+
* @example
|
|
904
|
+
* ```ts
|
|
905
|
+
* const endpoint = createEndpoint("/path", {
|
|
906
|
+
* method: "POST",
|
|
907
|
+
* body: z.record(z.string()),
|
|
908
|
+
* $Infer: {
|
|
909
|
+
* body: {} as {
|
|
910
|
+
* type: InferTypeFromOptions<Option> // custom type inference
|
|
911
|
+
* }
|
|
912
|
+
* }
|
|
913
|
+
* }, async(ctx)=>{
|
|
914
|
+
* const body = ctx.body
|
|
915
|
+
* })
|
|
916
|
+
* ```
|
|
917
|
+
*/
|
|
918
|
+
$Infer?: {
|
|
919
|
+
/**
|
|
920
|
+
* Body
|
|
921
|
+
*/
|
|
922
|
+
body?: any;
|
|
923
|
+
/**
|
|
924
|
+
* Query
|
|
925
|
+
*/
|
|
926
|
+
query?: Record<string, any>;
|
|
927
|
+
};
|
|
928
|
+
/**
|
|
929
|
+
* If enabled, endpoint won't be exposed over a router
|
|
930
|
+
*/
|
|
931
|
+
SERVER_ONLY?: boolean;
|
|
932
|
+
/**
|
|
933
|
+
* Extra metadata
|
|
934
|
+
*/
|
|
935
|
+
[key: string]: any;
|
|
936
|
+
};
|
|
937
|
+
/**
|
|
938
|
+
* List of middlewares to use
|
|
939
|
+
*/
|
|
940
|
+
use?: Middleware[];
|
|
941
|
+
/**
|
|
942
|
+
* A callback to run before any API error is throw or returned
|
|
943
|
+
*
|
|
944
|
+
* @param e - The API error
|
|
945
|
+
* @returns - The response to return
|
|
946
|
+
*/
|
|
947
|
+
onAPIError?: (e: APIError) => void | Promise<void>;
|
|
948
|
+
}
|
|
949
|
+
type EndpointContext<Path extends string, Options extends EndpointOptions, Context = {}> = {
|
|
950
|
+
/**
|
|
951
|
+
* Method
|
|
952
|
+
*
|
|
953
|
+
* The request method
|
|
954
|
+
*/
|
|
955
|
+
method: InferMethod<Options>;
|
|
956
|
+
/**
|
|
957
|
+
* Path
|
|
958
|
+
*
|
|
959
|
+
* The path of the endpoint
|
|
960
|
+
*/
|
|
961
|
+
path: Path;
|
|
962
|
+
/**
|
|
963
|
+
* Body
|
|
964
|
+
*
|
|
965
|
+
* The body object will be the parsed JSON from the request and validated
|
|
966
|
+
* against the body schema if it exists.
|
|
967
|
+
*/
|
|
968
|
+
body: InferBody<Options>;
|
|
969
|
+
/**
|
|
970
|
+
* Query
|
|
971
|
+
*
|
|
972
|
+
* The query object will be the parsed query string from the request
|
|
973
|
+
* and validated against the query schema if it exists
|
|
974
|
+
*/
|
|
975
|
+
query: InferQuery<Options>;
|
|
976
|
+
/**
|
|
977
|
+
* Params
|
|
978
|
+
*
|
|
979
|
+
* If the path is `/user/:id` and the request is `/user/1` then the params will
|
|
980
|
+
* be `{ id: "1" }` and if the path includes a wildcard like `/user/*` then the
|
|
981
|
+
* params will be `{ _: "1" }` where `_` is the wildcard key. If the wildcard
|
|
982
|
+
* is named like `/user/**:name` then the params will be `{ name: string }`
|
|
983
|
+
*/
|
|
984
|
+
params: InferParam<Path>;
|
|
985
|
+
/**
|
|
986
|
+
* Request object
|
|
987
|
+
*
|
|
988
|
+
* If `requireRequest` is set to true in the endpoint options this will be
|
|
989
|
+
* required
|
|
990
|
+
*/
|
|
991
|
+
request: InferRequest<Options>;
|
|
992
|
+
/**
|
|
993
|
+
* Headers
|
|
994
|
+
*
|
|
995
|
+
* If `requireHeaders` is set to true in the endpoint options this will be
|
|
996
|
+
* required
|
|
997
|
+
*/
|
|
998
|
+
headers: InferHeaders<Options>;
|
|
999
|
+
/**
|
|
1000
|
+
* Set header
|
|
1001
|
+
*
|
|
1002
|
+
* If it's called outside of a request it will just be ignored.
|
|
1003
|
+
*/
|
|
1004
|
+
setHeader: (key: string, value: string) => void;
|
|
1005
|
+
/**
|
|
1006
|
+
* Get header
|
|
1007
|
+
*
|
|
1008
|
+
* If it's called outside of a request it will just return null
|
|
1009
|
+
*
|
|
1010
|
+
* @param key - The key of the header
|
|
1011
|
+
* @returns
|
|
1012
|
+
*/
|
|
1013
|
+
getHeader: (key: string) => string | null;
|
|
1014
|
+
/**
|
|
1015
|
+
* Get a cookie value from the request
|
|
1016
|
+
*
|
|
1017
|
+
* @param key - The key of the cookie
|
|
1018
|
+
* @param prefix - The prefix of the cookie between `__Secure-` and `__Host-`
|
|
1019
|
+
* @returns - The value of the cookie
|
|
1020
|
+
*/
|
|
1021
|
+
getCookie: (key: string, prefix?: CookiePrefixOptions) => string | null;
|
|
1022
|
+
/**
|
|
1023
|
+
* Get a signed cookie value from the request
|
|
1024
|
+
*
|
|
1025
|
+
* @param key - The key of the cookie
|
|
1026
|
+
* @param secret - The secret of the signed cookie
|
|
1027
|
+
* @param prefix - The prefix of the cookie between `__Secure-` and `__Host-`
|
|
1028
|
+
* @returns
|
|
1029
|
+
*/
|
|
1030
|
+
getSignedCookie: (key: string, secret: string, prefix?: CookiePrefixOptions) => Promise<string | null>;
|
|
1031
|
+
/**
|
|
1032
|
+
* Set a cookie value in the response
|
|
1033
|
+
*
|
|
1034
|
+
* @param key - The key of the cookie
|
|
1035
|
+
* @param value - The value to set
|
|
1036
|
+
* @param options - The options of the cookie
|
|
1037
|
+
* @returns - The cookie string
|
|
1038
|
+
*/
|
|
1039
|
+
setCookie: (key: string, value: string, options?: CookieOptions) => string;
|
|
1040
|
+
/**
|
|
1041
|
+
* Set signed cookie
|
|
1042
|
+
*
|
|
1043
|
+
* @param key - The key of the cookie
|
|
1044
|
+
* @param value - The value to set
|
|
1045
|
+
* @param secret - The secret to sign the cookie with
|
|
1046
|
+
* @param options - The options of the cookie
|
|
1047
|
+
* @returns - The cookie string
|
|
1048
|
+
*/
|
|
1049
|
+
setSignedCookie: (key: string, value: string, secret: string, options?: CookieOptions) => Promise<string>;
|
|
1050
|
+
/**
|
|
1051
|
+
* JSON
|
|
1052
|
+
*
|
|
1053
|
+
* a helper function to create a JSON response with
|
|
1054
|
+
* the correct headers
|
|
1055
|
+
* and status code. If `asResponse` is set to true in
|
|
1056
|
+
* the context then
|
|
1057
|
+
* it will return a Response object instead of the
|
|
1058
|
+
* JSON object.
|
|
1059
|
+
*
|
|
1060
|
+
* @param json - The JSON object to return
|
|
1061
|
+
* @param routerResponse - The response object to
|
|
1062
|
+
* return if `asResponse` is
|
|
1063
|
+
* true in the context this will take precedence
|
|
1064
|
+
*/
|
|
1065
|
+
json: <R extends Record<string, any> | null>(json: R, routerResponse?: {
|
|
1066
|
+
status?: number;
|
|
1067
|
+
headers?: Record<string, string>;
|
|
1068
|
+
response?: Response;
|
|
1069
|
+
body?: Record<string, string>;
|
|
1070
|
+
} | Response) => Promise<R>;
|
|
1071
|
+
/**
|
|
1072
|
+
* Middleware context
|
|
1073
|
+
*/
|
|
1074
|
+
context: Prettify<Context & InferUse<Options["use"]>>;
|
|
1075
|
+
/**
|
|
1076
|
+
* Redirect to a new URL
|
|
1077
|
+
*/
|
|
1078
|
+
redirect: (url: string) => APIError;
|
|
1079
|
+
/**
|
|
1080
|
+
* Return error
|
|
1081
|
+
*/
|
|
1082
|
+
error: (status: keyof typeof _statusCode | Status, body?: {
|
|
1083
|
+
message?: string;
|
|
1084
|
+
code?: string;
|
|
1085
|
+
} & Record<string, any>, headers?: HeadersInit) => APIError;
|
|
1086
|
+
};
|
|
1087
|
+
declare const originalHandlerSymbol: unique symbol;
|
|
1088
|
+
declare const createEndpoint: {
|
|
1089
|
+
<Path extends string, Options extends EndpointOptions, R extends Promise<any>>(path: Path, options: Options, handler: (context: EndpointContext<Path, Options>) => R): {
|
|
1090
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Options>> extends true ? [InputContext<Path, Options> & {
|
|
1091
|
+
asResponse?: AsResponse;
|
|
1092
|
+
returnHeaders?: ReturnHeaders;
|
|
1093
|
+
}] : [(InputContext<Path, Options> & {
|
|
1094
|
+
asResponse?: AsResponse;
|
|
1095
|
+
returnHeaders?: ReturnHeaders;
|
|
1096
|
+
})?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
1097
|
+
headers: Headers;
|
|
1098
|
+
response: Awaited<R>;
|
|
1099
|
+
} : Awaited<R>>;
|
|
1100
|
+
wrap<T>(fn: (context: EndpointContext<Path, Options>, original: (context: EndpointContext<Path, Options>) => Promise<R>) => T): {
|
|
1101
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Options>> extends true ? [InferBodyInput<Options, Options["metadata"] extends {
|
|
1102
|
+
$Infer: {
|
|
1103
|
+
body: infer B;
|
|
1104
|
+
};
|
|
1105
|
+
} ? B : Options["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["body"]> : undefined> & InferInputMethod<Options, Options["method"] extends any[] ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> & InferQueryInput<Options, Options["metadata"] extends {
|
|
1106
|
+
$Infer: {
|
|
1107
|
+
query: infer Query;
|
|
1108
|
+
};
|
|
1109
|
+
} ? Query : Options["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
1110
|
+
asResponse?: boolean;
|
|
1111
|
+
returnHeaders?: boolean;
|
|
1112
|
+
use?: Middleware[];
|
|
1113
|
+
path?: string;
|
|
1114
|
+
} & {
|
|
1115
|
+
asResponse?: AsResponse | undefined;
|
|
1116
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1117
|
+
}] : [((InferBodyInput<Options, Options["metadata"] extends {
|
|
1118
|
+
$Infer: {
|
|
1119
|
+
body: infer B;
|
|
1120
|
+
};
|
|
1121
|
+
} ? B : Options["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["body"]> : undefined> & InferInputMethod<Options, Options["method"] extends any[] ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> & InferQueryInput<Options, Options["metadata"] extends {
|
|
1122
|
+
$Infer: {
|
|
1123
|
+
query: infer Query;
|
|
1124
|
+
};
|
|
1125
|
+
} ? Query : Options["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
1126
|
+
asResponse?: boolean;
|
|
1127
|
+
returnHeaders?: boolean;
|
|
1128
|
+
use?: Middleware[];
|
|
1129
|
+
path?: string;
|
|
1130
|
+
} & {
|
|
1131
|
+
asResponse?: AsResponse | undefined;
|
|
1132
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1133
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
1134
|
+
headers: Headers;
|
|
1135
|
+
response: Awaited<T>;
|
|
1136
|
+
} : Awaited<T>>;
|
|
1137
|
+
wrap<T_1>(fn: (context: EndpointContext<Path, Options>, original: (context: EndpointContext<Path, Options>) => Promise<Promise<T>>) => T_1): {
|
|
1138
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Options>> extends true ? [InferBodyInput<Options, Options["metadata"] extends {
|
|
1139
|
+
$Infer: {
|
|
1140
|
+
body: infer B;
|
|
1141
|
+
};
|
|
1142
|
+
} ? B : Options["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["body"]> : undefined> & InferInputMethod<Options, Options["method"] extends any[] ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> & InferQueryInput<Options, Options["metadata"] extends {
|
|
1143
|
+
$Infer: {
|
|
1144
|
+
query: infer Query;
|
|
1145
|
+
};
|
|
1146
|
+
} ? Query : Options["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
1147
|
+
asResponse?: boolean;
|
|
1148
|
+
returnHeaders?: boolean;
|
|
1149
|
+
use?: Middleware[];
|
|
1150
|
+
path?: string;
|
|
1151
|
+
} & {
|
|
1152
|
+
asResponse?: AsResponse | undefined;
|
|
1153
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1154
|
+
}] : [((InferBodyInput<Options, Options["metadata"] extends {
|
|
1155
|
+
$Infer: {
|
|
1156
|
+
body: infer B;
|
|
1157
|
+
};
|
|
1158
|
+
} ? B : Options["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["body"]> : undefined> & InferInputMethod<Options, Options["method"] extends any[] ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> & InferQueryInput<Options, Options["metadata"] extends {
|
|
1159
|
+
$Infer: {
|
|
1160
|
+
query: infer Query;
|
|
1161
|
+
};
|
|
1162
|
+
} ? Query : Options["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
1163
|
+
asResponse?: boolean;
|
|
1164
|
+
returnHeaders?: boolean;
|
|
1165
|
+
use?: Middleware[];
|
|
1166
|
+
path?: string;
|
|
1167
|
+
} & {
|
|
1168
|
+
asResponse?: AsResponse | undefined;
|
|
1169
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1170
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
1171
|
+
headers: Headers;
|
|
1172
|
+
response: Awaited<T_1>;
|
|
1173
|
+
} : Awaited<T_1>>;
|
|
1174
|
+
wrap<T_2>(fn: (context: EndpointContext<Path, Options>, original: (context: EndpointContext<Path, Options>) => Promise<Promise<T_1>>) => T_2): {
|
|
1175
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Options>> extends true ? [InferBodyInput<Options, Options["metadata"] extends {
|
|
1176
|
+
$Infer: {
|
|
1177
|
+
body: infer B;
|
|
1178
|
+
};
|
|
1179
|
+
} ? B : Options["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["body"]> : undefined> & InferInputMethod<Options, Options["method"] extends any[] ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> & InferQueryInput<Options, Options["metadata"] extends {
|
|
1180
|
+
$Infer: {
|
|
1181
|
+
query: infer Query;
|
|
1182
|
+
};
|
|
1183
|
+
} ? Query : Options["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
1184
|
+
asResponse?: boolean;
|
|
1185
|
+
returnHeaders?: boolean;
|
|
1186
|
+
use?: Middleware[];
|
|
1187
|
+
path?: string;
|
|
1188
|
+
} & {
|
|
1189
|
+
asResponse?: AsResponse | undefined;
|
|
1190
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1191
|
+
}] : [((InferBodyInput<Options, Options["metadata"] extends {
|
|
1192
|
+
$Infer: {
|
|
1193
|
+
body: infer B;
|
|
1194
|
+
};
|
|
1195
|
+
} ? B : Options["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["body"]> : undefined> & InferInputMethod<Options, Options["method"] extends any[] ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> & InferQueryInput<Options, Options["metadata"] extends {
|
|
1196
|
+
$Infer: {
|
|
1197
|
+
query: infer Query;
|
|
1198
|
+
};
|
|
1199
|
+
} ? Query : Options["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
1200
|
+
asResponse?: boolean;
|
|
1201
|
+
returnHeaders?: boolean;
|
|
1202
|
+
use?: Middleware[];
|
|
1203
|
+
path?: string;
|
|
1204
|
+
} & {
|
|
1205
|
+
asResponse?: AsResponse | undefined;
|
|
1206
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1207
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
1208
|
+
headers: Headers;
|
|
1209
|
+
response: Awaited<T_2>;
|
|
1210
|
+
} : Awaited<T_2>>;
|
|
1211
|
+
wrap<T_3>(fn: (context: EndpointContext<Path, Options>, original: (context: EndpointContext<Path, Options>) => Promise<Promise<T_2>>) => T_3): {
|
|
1212
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Options>> extends true ? [InferBodyInput<Options, Options["metadata"] extends {
|
|
1213
|
+
$Infer: {
|
|
1214
|
+
body: infer B;
|
|
1215
|
+
};
|
|
1216
|
+
} ? B : Options["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["body"]> : undefined> & InferInputMethod<Options, Options["method"] extends any[] ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> & InferQueryInput<Options, Options["metadata"] extends {
|
|
1217
|
+
$Infer: {
|
|
1218
|
+
query: infer Query;
|
|
1219
|
+
};
|
|
1220
|
+
} ? Query : Options["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
1221
|
+
asResponse?: boolean;
|
|
1222
|
+
returnHeaders?: boolean;
|
|
1223
|
+
use?: Middleware[];
|
|
1224
|
+
path?: string;
|
|
1225
|
+
} & {
|
|
1226
|
+
asResponse?: AsResponse | undefined;
|
|
1227
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1228
|
+
}] : [((InferBodyInput<Options, Options["metadata"] extends {
|
|
1229
|
+
$Infer: {
|
|
1230
|
+
body: infer B;
|
|
1231
|
+
};
|
|
1232
|
+
} ? B : Options["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["body"]> : undefined> & InferInputMethod<Options, Options["method"] extends any[] ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> & InferQueryInput<Options, Options["metadata"] extends {
|
|
1233
|
+
$Infer: {
|
|
1234
|
+
query: infer Query;
|
|
1235
|
+
};
|
|
1236
|
+
} ? Query : Options["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
1237
|
+
asResponse?: boolean;
|
|
1238
|
+
returnHeaders?: boolean;
|
|
1239
|
+
use?: Middleware[];
|
|
1240
|
+
path?: string;
|
|
1241
|
+
} & {
|
|
1242
|
+
asResponse?: AsResponse | undefined;
|
|
1243
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1244
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
1245
|
+
headers: Headers;
|
|
1246
|
+
response: Awaited<T_3>;
|
|
1247
|
+
} : Awaited<T_3>>;
|
|
1248
|
+
wrap<T_4>(fn: (context: EndpointContext<Path, Options>, original: (context: EndpointContext<Path, Options>) => Promise<Promise<T_3>>) => T_4): {
|
|
1249
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Options>> extends true ? [InferBodyInput<Options, Options["metadata"] extends {
|
|
1250
|
+
$Infer: {
|
|
1251
|
+
body: infer B;
|
|
1252
|
+
};
|
|
1253
|
+
} ? B : Options["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["body"]> : undefined> & InferInputMethod<Options, Options["method"] extends any[] ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> & InferQueryInput<Options, Options["metadata"] extends {
|
|
1254
|
+
$Infer: {
|
|
1255
|
+
query: infer Query;
|
|
1256
|
+
};
|
|
1257
|
+
} ? Query : Options["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
1258
|
+
asResponse?: boolean;
|
|
1259
|
+
returnHeaders?: boolean;
|
|
1260
|
+
use?: Middleware[];
|
|
1261
|
+
path?: string;
|
|
1262
|
+
} & {
|
|
1263
|
+
asResponse?: AsResponse | undefined;
|
|
1264
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1265
|
+
}] : [((InferBodyInput<Options, Options["metadata"] extends {
|
|
1266
|
+
$Infer: {
|
|
1267
|
+
body: infer B;
|
|
1268
|
+
};
|
|
1269
|
+
} ? B : Options["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["body"]> : undefined> & InferInputMethod<Options, Options["method"] extends any[] ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> & InferQueryInput<Options, Options["metadata"] extends {
|
|
1270
|
+
$Infer: {
|
|
1271
|
+
query: infer Query;
|
|
1272
|
+
};
|
|
1273
|
+
} ? Query : Options["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
1274
|
+
asResponse?: boolean;
|
|
1275
|
+
returnHeaders?: boolean;
|
|
1276
|
+
use?: Middleware[];
|
|
1277
|
+
path?: string;
|
|
1278
|
+
} & {
|
|
1279
|
+
asResponse?: AsResponse | undefined;
|
|
1280
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1281
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
1282
|
+
headers: Headers;
|
|
1283
|
+
response: Awaited<T_4>;
|
|
1284
|
+
} : Awaited<T_4>>;
|
|
1285
|
+
wrap<T_5>(fn: (context: EndpointContext<Path, Options>, original: (context: EndpointContext<Path, Options>) => Promise<Promise<T_4>>) => T_5): {
|
|
1286
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Options>> extends true ? [InferBodyInput<Options, Options["metadata"] extends {
|
|
1287
|
+
$Infer: {
|
|
1288
|
+
body: infer B;
|
|
1289
|
+
};
|
|
1290
|
+
} ? B : Options["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["body"]> : undefined> & InferInputMethod<Options, Options["method"] extends any[] ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> & InferQueryInput<Options, Options["metadata"] extends {
|
|
1291
|
+
$Infer: {
|
|
1292
|
+
query: infer Query;
|
|
1293
|
+
};
|
|
1294
|
+
} ? Query : Options["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
1295
|
+
asResponse?: boolean;
|
|
1296
|
+
returnHeaders?: boolean;
|
|
1297
|
+
use?: Middleware[];
|
|
1298
|
+
path?: string;
|
|
1299
|
+
} & {
|
|
1300
|
+
asResponse?: AsResponse | undefined;
|
|
1301
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1302
|
+
}] : [((InferBodyInput<Options, Options["metadata"] extends {
|
|
1303
|
+
$Infer: {
|
|
1304
|
+
body: infer B;
|
|
1305
|
+
};
|
|
1306
|
+
} ? B : Options["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["body"]> : undefined> & InferInputMethod<Options, Options["method"] extends any[] ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> & InferQueryInput<Options, Options["metadata"] extends {
|
|
1307
|
+
$Infer: {
|
|
1308
|
+
query: infer Query;
|
|
1309
|
+
};
|
|
1310
|
+
} ? Query : Options["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
1311
|
+
asResponse?: boolean;
|
|
1312
|
+
returnHeaders?: boolean;
|
|
1313
|
+
use?: Middleware[];
|
|
1314
|
+
path?: string;
|
|
1315
|
+
} & {
|
|
1316
|
+
asResponse?: AsResponse | undefined;
|
|
1317
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1318
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
1319
|
+
headers: Headers;
|
|
1320
|
+
response: Awaited<T_5>;
|
|
1321
|
+
} : Awaited<T_5>>;
|
|
1322
|
+
wrap<T_6>(fn: (context: EndpointContext<Path, Options>, original: (context: EndpointContext<Path, Options>) => Promise<Promise<T_5>>) => T_6): {
|
|
1323
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Options>> extends true ? [InferBodyInput<Options, Options["metadata"] extends {
|
|
1324
|
+
$Infer: {
|
|
1325
|
+
body: infer B;
|
|
1326
|
+
};
|
|
1327
|
+
} ? B : Options["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["body"]> : undefined> & InferInputMethod<Options, Options["method"] extends any[] ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> & InferQueryInput<Options, Options["metadata"] extends {
|
|
1328
|
+
$Infer: {
|
|
1329
|
+
query: infer Query;
|
|
1330
|
+
};
|
|
1331
|
+
} ? Query : Options["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
1332
|
+
asResponse?: boolean;
|
|
1333
|
+
returnHeaders?: boolean;
|
|
1334
|
+
use?: Middleware[];
|
|
1335
|
+
path?: string;
|
|
1336
|
+
} & {
|
|
1337
|
+
asResponse?: AsResponse | undefined;
|
|
1338
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1339
|
+
}] : [((InferBodyInput<Options, Options["metadata"] extends {
|
|
1340
|
+
$Infer: {
|
|
1341
|
+
body: infer B;
|
|
1342
|
+
};
|
|
1343
|
+
} ? B : Options["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["body"]> : undefined> & InferInputMethod<Options, Options["method"] extends any[] ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> & InferQueryInput<Options, Options["metadata"] extends {
|
|
1344
|
+
$Infer: {
|
|
1345
|
+
query: infer Query;
|
|
1346
|
+
};
|
|
1347
|
+
} ? Query : Options["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
1348
|
+
asResponse?: boolean;
|
|
1349
|
+
returnHeaders?: boolean;
|
|
1350
|
+
use?: Middleware[];
|
|
1351
|
+
path?: string;
|
|
1352
|
+
} & {
|
|
1353
|
+
asResponse?: AsResponse | undefined;
|
|
1354
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1355
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
1356
|
+
headers: Headers;
|
|
1357
|
+
response: Awaited<T_6>;
|
|
1358
|
+
} : Awaited<T_6>>;
|
|
1359
|
+
wrap<T_7>(fn: (context: EndpointContext<Path, Options>, original: (context: EndpointContext<Path, Options>) => Promise<Promise<T_6>>) => T_7): {
|
|
1360
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Options>> extends true ? [InferBodyInput<Options, Options["metadata"] extends {
|
|
1361
|
+
$Infer: {
|
|
1362
|
+
body: infer B;
|
|
1363
|
+
};
|
|
1364
|
+
} ? B : Options["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["body"]> : undefined> & InferInputMethod<Options, Options["method"] extends any[] ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> & InferQueryInput<Options, Options["metadata"] extends {
|
|
1365
|
+
$Infer: {
|
|
1366
|
+
query: infer Query;
|
|
1367
|
+
};
|
|
1368
|
+
} ? Query : Options["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
1369
|
+
asResponse?: boolean;
|
|
1370
|
+
returnHeaders?: boolean;
|
|
1371
|
+
use?: Middleware[];
|
|
1372
|
+
path?: string;
|
|
1373
|
+
} & {
|
|
1374
|
+
asResponse?: AsResponse | undefined;
|
|
1375
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1376
|
+
}] : [((InferBodyInput<Options, Options["metadata"] extends {
|
|
1377
|
+
$Infer: {
|
|
1378
|
+
body: infer B;
|
|
1379
|
+
};
|
|
1380
|
+
} ? B : Options["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["body"]> : undefined> & InferInputMethod<Options, Options["method"] extends any[] ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> & InferQueryInput<Options, Options["metadata"] extends {
|
|
1381
|
+
$Infer: {
|
|
1382
|
+
query: infer Query;
|
|
1383
|
+
};
|
|
1384
|
+
} ? Query : Options["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
1385
|
+
asResponse?: boolean;
|
|
1386
|
+
returnHeaders?: boolean;
|
|
1387
|
+
use?: Middleware[];
|
|
1388
|
+
path?: string;
|
|
1389
|
+
} & {
|
|
1390
|
+
asResponse?: AsResponse | undefined;
|
|
1391
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1392
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
1393
|
+
headers: Headers;
|
|
1394
|
+
response: Awaited<T_7>;
|
|
1395
|
+
} : Awaited<T_7>>;
|
|
1396
|
+
wrap<T_8>(fn: (context: EndpointContext<Path, Options>, original: (context: EndpointContext<Path, Options>) => Promise<Promise<T_7>>) => T_8): {
|
|
1397
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Options>> extends true ? [InferBodyInput<Options, Options["metadata"] extends {
|
|
1398
|
+
$Infer: {
|
|
1399
|
+
body: infer B;
|
|
1400
|
+
};
|
|
1401
|
+
} ? B : Options["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["body"]> : undefined> & InferInputMethod<Options, Options["method"] extends any[] ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> & InferQueryInput<Options, Options["metadata"] extends {
|
|
1402
|
+
$Infer: {
|
|
1403
|
+
query: infer Query;
|
|
1404
|
+
};
|
|
1405
|
+
} ? Query : Options["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
1406
|
+
asResponse?: boolean;
|
|
1407
|
+
returnHeaders?: boolean;
|
|
1408
|
+
use?: Middleware[];
|
|
1409
|
+
path?: string;
|
|
1410
|
+
} & {
|
|
1411
|
+
asResponse?: AsResponse | undefined;
|
|
1412
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1413
|
+
}] : [((InferBodyInput<Options, Options["metadata"] extends {
|
|
1414
|
+
$Infer: {
|
|
1415
|
+
body: infer B;
|
|
1416
|
+
};
|
|
1417
|
+
} ? B : Options["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["body"]> : undefined> & InferInputMethod<Options, Options["method"] extends any[] ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> & InferQueryInput<Options, Options["metadata"] extends {
|
|
1418
|
+
$Infer: {
|
|
1419
|
+
query: infer Query;
|
|
1420
|
+
};
|
|
1421
|
+
} ? Query : Options["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
1422
|
+
asResponse?: boolean;
|
|
1423
|
+
returnHeaders?: boolean;
|
|
1424
|
+
use?: Middleware[];
|
|
1425
|
+
path?: string;
|
|
1426
|
+
} & {
|
|
1427
|
+
asResponse?: AsResponse | undefined;
|
|
1428
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1429
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
1430
|
+
headers: Headers;
|
|
1431
|
+
response: Awaited<T_8>;
|
|
1432
|
+
} : Awaited<T_8>>;
|
|
1433
|
+
wrap<T_9>(fn: (context: EndpointContext<Path, Options>, original: (context: EndpointContext<Path, Options>) => Promise<Promise<T_8>>) => T_9): {
|
|
1434
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Options>> extends true ? [InferBodyInput<Options, Options["metadata"] extends {
|
|
1435
|
+
$Infer: {
|
|
1436
|
+
body: infer B;
|
|
1437
|
+
};
|
|
1438
|
+
} ? B : Options["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["body"]> : undefined> & InferInputMethod<Options, Options["method"] extends any[] ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> & InferQueryInput<Options, Options["metadata"] extends {
|
|
1439
|
+
$Infer: {
|
|
1440
|
+
query: infer Query;
|
|
1441
|
+
};
|
|
1442
|
+
} ? Query : Options["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
1443
|
+
asResponse?: boolean;
|
|
1444
|
+
returnHeaders?: boolean;
|
|
1445
|
+
use?: Middleware[];
|
|
1446
|
+
path?: string;
|
|
1447
|
+
} & {
|
|
1448
|
+
asResponse?: AsResponse | undefined;
|
|
1449
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1450
|
+
}] : [((InferBodyInput<Options, Options["metadata"] extends {
|
|
1451
|
+
$Infer: {
|
|
1452
|
+
body: infer B;
|
|
1453
|
+
};
|
|
1454
|
+
} ? B : Options["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["body"]> : undefined> & InferInputMethod<Options, Options["method"] extends any[] ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined> & InferQueryInput<Options, Options["metadata"] extends {
|
|
1455
|
+
$Infer: {
|
|
1456
|
+
query: infer Query;
|
|
1457
|
+
};
|
|
1458
|
+
} ? Query : Options["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
|
|
1459
|
+
asResponse?: boolean;
|
|
1460
|
+
returnHeaders?: boolean;
|
|
1461
|
+
use?: Middleware[];
|
|
1462
|
+
path?: string;
|
|
1463
|
+
} & {
|
|
1464
|
+
asResponse?: AsResponse | undefined;
|
|
1465
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1466
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
1467
|
+
headers: Headers;
|
|
1468
|
+
response: Awaited<T_9>;
|
|
1469
|
+
} : Awaited<T_9>>;
|
|
1470
|
+
wrap<T_10>(fn: (context: EndpointContext<Path, Options>, original: (context: EndpointContext<Path, Options>) => Promise<Promise<T_9>>) => T_10): /*elided*/ any;
|
|
1471
|
+
options: Options;
|
|
1472
|
+
path: Path;
|
|
1473
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Options>) => Promise<T_9>;
|
|
1474
|
+
};
|
|
1475
|
+
options: Options;
|
|
1476
|
+
path: Path;
|
|
1477
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Options>) => Promise<T_8>;
|
|
1478
|
+
};
|
|
1479
|
+
options: Options;
|
|
1480
|
+
path: Path;
|
|
1481
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Options>) => Promise<T_7>;
|
|
1482
|
+
};
|
|
1483
|
+
options: Options;
|
|
1484
|
+
path: Path;
|
|
1485
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Options>) => Promise<T_6>;
|
|
1486
|
+
};
|
|
1487
|
+
options: Options;
|
|
1488
|
+
path: Path;
|
|
1489
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Options>) => Promise<T_5>;
|
|
1490
|
+
};
|
|
1491
|
+
options: Options;
|
|
1492
|
+
path: Path;
|
|
1493
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Options>) => Promise<T_4>;
|
|
1494
|
+
};
|
|
1495
|
+
options: Options;
|
|
1496
|
+
path: Path;
|
|
1497
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Options>) => Promise<T_3>;
|
|
1498
|
+
};
|
|
1499
|
+
options: Options;
|
|
1500
|
+
path: Path;
|
|
1501
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Options>) => Promise<T_2>;
|
|
1502
|
+
};
|
|
1503
|
+
options: Options;
|
|
1504
|
+
path: Path;
|
|
1505
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Options>) => Promise<T_1>;
|
|
1506
|
+
};
|
|
1507
|
+
options: Options;
|
|
1508
|
+
path: Path;
|
|
1509
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Options>) => Promise<T>;
|
|
1510
|
+
};
|
|
1511
|
+
options: Options;
|
|
1512
|
+
path: Path;
|
|
1513
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Options>) => R;
|
|
1514
|
+
};
|
|
1515
|
+
create<E extends {
|
|
1516
|
+
use?: Middleware[];
|
|
1517
|
+
}>(opts?: E): <Path extends string, Opts extends EndpointOptions, R extends Promise<any>>(path: Path, options: Opts, handler: (ctx: EndpointContext<Path, Opts, InferUse<E["use"]>>) => R) => {
|
|
1518
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Opts & {
|
|
1519
|
+
use: any[];
|
|
1520
|
+
}>> extends true ? [InferBodyInput<Opts & {
|
|
1521
|
+
use: any[];
|
|
1522
|
+
}, (Opts & {
|
|
1523
|
+
use: any[];
|
|
1524
|
+
})["metadata"] extends {
|
|
1525
|
+
$Infer: {
|
|
1526
|
+
body: infer B;
|
|
1527
|
+
};
|
|
1528
|
+
} ? B : (Opts & {
|
|
1529
|
+
use: any[];
|
|
1530
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
1531
|
+
use: any[];
|
|
1532
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
1533
|
+
use: any[];
|
|
1534
|
+
}, (Opts & {
|
|
1535
|
+
use: any[];
|
|
1536
|
+
})["method"] extends any[] ? (Opts & {
|
|
1537
|
+
use: any[];
|
|
1538
|
+
})["method"][number] : (Opts & {
|
|
1539
|
+
use: any[];
|
|
1540
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
1541
|
+
use: any[];
|
|
1542
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
1543
|
+
use: any[];
|
|
1544
|
+
}, (Opts & {
|
|
1545
|
+
use: any[];
|
|
1546
|
+
})["metadata"] extends {
|
|
1547
|
+
$Infer: {
|
|
1548
|
+
query: infer Query;
|
|
1549
|
+
};
|
|
1550
|
+
} ? Query : (Opts & {
|
|
1551
|
+
use: any[];
|
|
1552
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
1553
|
+
use: any[];
|
|
1554
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
1555
|
+
use: any[];
|
|
1556
|
+
}> & InferHeadersInput<Opts & {
|
|
1557
|
+
use: any[];
|
|
1558
|
+
}> & {
|
|
1559
|
+
asResponse?: boolean;
|
|
1560
|
+
returnHeaders?: boolean;
|
|
1561
|
+
use?: Middleware[];
|
|
1562
|
+
path?: string;
|
|
1563
|
+
} & {
|
|
1564
|
+
asResponse?: AsResponse | undefined;
|
|
1565
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1566
|
+
}] : [((InferBodyInput<Opts & {
|
|
1567
|
+
use: any[];
|
|
1568
|
+
}, (Opts & {
|
|
1569
|
+
use: any[];
|
|
1570
|
+
})["metadata"] extends {
|
|
1571
|
+
$Infer: {
|
|
1572
|
+
body: infer B;
|
|
1573
|
+
};
|
|
1574
|
+
} ? B : (Opts & {
|
|
1575
|
+
use: any[];
|
|
1576
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
1577
|
+
use: any[];
|
|
1578
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
1579
|
+
use: any[];
|
|
1580
|
+
}, (Opts & {
|
|
1581
|
+
use: any[];
|
|
1582
|
+
})["method"] extends any[] ? (Opts & {
|
|
1583
|
+
use: any[];
|
|
1584
|
+
})["method"][number] : (Opts & {
|
|
1585
|
+
use: any[];
|
|
1586
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
1587
|
+
use: any[];
|
|
1588
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
1589
|
+
use: any[];
|
|
1590
|
+
}, (Opts & {
|
|
1591
|
+
use: any[];
|
|
1592
|
+
})["metadata"] extends {
|
|
1593
|
+
$Infer: {
|
|
1594
|
+
query: infer Query;
|
|
1595
|
+
};
|
|
1596
|
+
} ? Query : (Opts & {
|
|
1597
|
+
use: any[];
|
|
1598
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
1599
|
+
use: any[];
|
|
1600
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
1601
|
+
use: any[];
|
|
1602
|
+
}> & InferHeadersInput<Opts & {
|
|
1603
|
+
use: any[];
|
|
1604
|
+
}> & {
|
|
1605
|
+
asResponse?: boolean;
|
|
1606
|
+
returnHeaders?: boolean;
|
|
1607
|
+
use?: Middleware[];
|
|
1608
|
+
path?: string;
|
|
1609
|
+
} & {
|
|
1610
|
+
asResponse?: AsResponse | undefined;
|
|
1611
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1612
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
1613
|
+
headers: Headers;
|
|
1614
|
+
response: Awaited<R>;
|
|
1615
|
+
} : Awaited<R>>;
|
|
1616
|
+
wrap<T>(fn: (context: EndpointContext<Path, Opts & {
|
|
1617
|
+
use: any[];
|
|
1618
|
+
}, {}>, original: (context: EndpointContext<Path, Opts & {
|
|
1619
|
+
use: any[];
|
|
1620
|
+
}, {}>) => Promise<R>) => T): {
|
|
1621
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Opts & {
|
|
1622
|
+
use: any[];
|
|
1623
|
+
}>> extends true ? [InferBodyInput<Opts & {
|
|
1624
|
+
use: any[];
|
|
1625
|
+
}, (Opts & {
|
|
1626
|
+
use: any[];
|
|
1627
|
+
})["metadata"] extends {
|
|
1628
|
+
$Infer: {
|
|
1629
|
+
body: infer B;
|
|
1630
|
+
};
|
|
1631
|
+
} ? B : (Opts & {
|
|
1632
|
+
use: any[];
|
|
1633
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
1634
|
+
use: any[];
|
|
1635
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
1636
|
+
use: any[];
|
|
1637
|
+
}, (Opts & {
|
|
1638
|
+
use: any[];
|
|
1639
|
+
})["method"] extends any[] ? (Opts & {
|
|
1640
|
+
use: any[];
|
|
1641
|
+
})["method"][number] : (Opts & {
|
|
1642
|
+
use: any[];
|
|
1643
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
1644
|
+
use: any[];
|
|
1645
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
1646
|
+
use: any[];
|
|
1647
|
+
}, (Opts & {
|
|
1648
|
+
use: any[];
|
|
1649
|
+
})["metadata"] extends {
|
|
1650
|
+
$Infer: {
|
|
1651
|
+
query: infer Query;
|
|
1652
|
+
};
|
|
1653
|
+
} ? Query : (Opts & {
|
|
1654
|
+
use: any[];
|
|
1655
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
1656
|
+
use: any[];
|
|
1657
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
1658
|
+
use: any[];
|
|
1659
|
+
}> & InferHeadersInput<Opts & {
|
|
1660
|
+
use: any[];
|
|
1661
|
+
}> & {
|
|
1662
|
+
asResponse?: boolean;
|
|
1663
|
+
returnHeaders?: boolean;
|
|
1664
|
+
use?: Middleware[];
|
|
1665
|
+
path?: string;
|
|
1666
|
+
} & {
|
|
1667
|
+
asResponse?: AsResponse | undefined;
|
|
1668
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1669
|
+
}] : [((InferBodyInput<Opts & {
|
|
1670
|
+
use: any[];
|
|
1671
|
+
}, (Opts & {
|
|
1672
|
+
use: any[];
|
|
1673
|
+
})["metadata"] extends {
|
|
1674
|
+
$Infer: {
|
|
1675
|
+
body: infer B;
|
|
1676
|
+
};
|
|
1677
|
+
} ? B : (Opts & {
|
|
1678
|
+
use: any[];
|
|
1679
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
1680
|
+
use: any[];
|
|
1681
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
1682
|
+
use: any[];
|
|
1683
|
+
}, (Opts & {
|
|
1684
|
+
use: any[];
|
|
1685
|
+
})["method"] extends any[] ? (Opts & {
|
|
1686
|
+
use: any[];
|
|
1687
|
+
})["method"][number] : (Opts & {
|
|
1688
|
+
use: any[];
|
|
1689
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
1690
|
+
use: any[];
|
|
1691
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
1692
|
+
use: any[];
|
|
1693
|
+
}, (Opts & {
|
|
1694
|
+
use: any[];
|
|
1695
|
+
})["metadata"] extends {
|
|
1696
|
+
$Infer: {
|
|
1697
|
+
query: infer Query;
|
|
1698
|
+
};
|
|
1699
|
+
} ? Query : (Opts & {
|
|
1700
|
+
use: any[];
|
|
1701
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
1702
|
+
use: any[];
|
|
1703
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
1704
|
+
use: any[];
|
|
1705
|
+
}> & InferHeadersInput<Opts & {
|
|
1706
|
+
use: any[];
|
|
1707
|
+
}> & {
|
|
1708
|
+
asResponse?: boolean;
|
|
1709
|
+
returnHeaders?: boolean;
|
|
1710
|
+
use?: Middleware[];
|
|
1711
|
+
path?: string;
|
|
1712
|
+
} & {
|
|
1713
|
+
asResponse?: AsResponse | undefined;
|
|
1714
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1715
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
1716
|
+
headers: Headers;
|
|
1717
|
+
response: Awaited<T>;
|
|
1718
|
+
} : Awaited<T>>;
|
|
1719
|
+
wrap<T_1>(fn: (context: EndpointContext<Path, Opts & {
|
|
1720
|
+
use: any[];
|
|
1721
|
+
}, {}>, original: (context: EndpointContext<Path, Opts & {
|
|
1722
|
+
use: any[];
|
|
1723
|
+
}, {}>) => Promise<Promise<T>>) => T_1): {
|
|
1724
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Opts & {
|
|
1725
|
+
use: any[];
|
|
1726
|
+
}>> extends true ? [InferBodyInput<Opts & {
|
|
1727
|
+
use: any[];
|
|
1728
|
+
}, (Opts & {
|
|
1729
|
+
use: any[];
|
|
1730
|
+
})["metadata"] extends {
|
|
1731
|
+
$Infer: {
|
|
1732
|
+
body: infer B;
|
|
1733
|
+
};
|
|
1734
|
+
} ? B : (Opts & {
|
|
1735
|
+
use: any[];
|
|
1736
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
1737
|
+
use: any[];
|
|
1738
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
1739
|
+
use: any[];
|
|
1740
|
+
}, (Opts & {
|
|
1741
|
+
use: any[];
|
|
1742
|
+
})["method"] extends any[] ? (Opts & {
|
|
1743
|
+
use: any[];
|
|
1744
|
+
})["method"][number] : (Opts & {
|
|
1745
|
+
use: any[];
|
|
1746
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
1747
|
+
use: any[];
|
|
1748
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
1749
|
+
use: any[];
|
|
1750
|
+
}, (Opts & {
|
|
1751
|
+
use: any[];
|
|
1752
|
+
})["metadata"] extends {
|
|
1753
|
+
$Infer: {
|
|
1754
|
+
query: infer Query;
|
|
1755
|
+
};
|
|
1756
|
+
} ? Query : (Opts & {
|
|
1757
|
+
use: any[];
|
|
1758
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
1759
|
+
use: any[];
|
|
1760
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
1761
|
+
use: any[];
|
|
1762
|
+
}> & InferHeadersInput<Opts & {
|
|
1763
|
+
use: any[];
|
|
1764
|
+
}> & {
|
|
1765
|
+
asResponse?: boolean;
|
|
1766
|
+
returnHeaders?: boolean;
|
|
1767
|
+
use?: Middleware[];
|
|
1768
|
+
path?: string;
|
|
1769
|
+
} & {
|
|
1770
|
+
asResponse?: AsResponse | undefined;
|
|
1771
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1772
|
+
}] : [((InferBodyInput<Opts & {
|
|
1773
|
+
use: any[];
|
|
1774
|
+
}, (Opts & {
|
|
1775
|
+
use: any[];
|
|
1776
|
+
})["metadata"] extends {
|
|
1777
|
+
$Infer: {
|
|
1778
|
+
body: infer B;
|
|
1779
|
+
};
|
|
1780
|
+
} ? B : (Opts & {
|
|
1781
|
+
use: any[];
|
|
1782
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
1783
|
+
use: any[];
|
|
1784
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
1785
|
+
use: any[];
|
|
1786
|
+
}, (Opts & {
|
|
1787
|
+
use: any[];
|
|
1788
|
+
})["method"] extends any[] ? (Opts & {
|
|
1789
|
+
use: any[];
|
|
1790
|
+
})["method"][number] : (Opts & {
|
|
1791
|
+
use: any[];
|
|
1792
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
1793
|
+
use: any[];
|
|
1794
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
1795
|
+
use: any[];
|
|
1796
|
+
}, (Opts & {
|
|
1797
|
+
use: any[];
|
|
1798
|
+
})["metadata"] extends {
|
|
1799
|
+
$Infer: {
|
|
1800
|
+
query: infer Query;
|
|
1801
|
+
};
|
|
1802
|
+
} ? Query : (Opts & {
|
|
1803
|
+
use: any[];
|
|
1804
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
1805
|
+
use: any[];
|
|
1806
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
1807
|
+
use: any[];
|
|
1808
|
+
}> & InferHeadersInput<Opts & {
|
|
1809
|
+
use: any[];
|
|
1810
|
+
}> & {
|
|
1811
|
+
asResponse?: boolean;
|
|
1812
|
+
returnHeaders?: boolean;
|
|
1813
|
+
use?: Middleware[];
|
|
1814
|
+
path?: string;
|
|
1815
|
+
} & {
|
|
1816
|
+
asResponse?: AsResponse | undefined;
|
|
1817
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1818
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
1819
|
+
headers: Headers;
|
|
1820
|
+
response: Awaited<T_1>;
|
|
1821
|
+
} : Awaited<T_1>>;
|
|
1822
|
+
wrap<T_2>(fn: (context: EndpointContext<Path, Opts & {
|
|
1823
|
+
use: any[];
|
|
1824
|
+
}, {}>, original: (context: EndpointContext<Path, Opts & {
|
|
1825
|
+
use: any[];
|
|
1826
|
+
}, {}>) => Promise<Promise<T_1>>) => T_2): {
|
|
1827
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Opts & {
|
|
1828
|
+
use: any[];
|
|
1829
|
+
}>> extends true ? [InferBodyInput<Opts & {
|
|
1830
|
+
use: any[];
|
|
1831
|
+
}, (Opts & {
|
|
1832
|
+
use: any[];
|
|
1833
|
+
})["metadata"] extends {
|
|
1834
|
+
$Infer: {
|
|
1835
|
+
body: infer B;
|
|
1836
|
+
};
|
|
1837
|
+
} ? B : (Opts & {
|
|
1838
|
+
use: any[];
|
|
1839
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
1840
|
+
use: any[];
|
|
1841
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
1842
|
+
use: any[];
|
|
1843
|
+
}, (Opts & {
|
|
1844
|
+
use: any[];
|
|
1845
|
+
})["method"] extends any[] ? (Opts & {
|
|
1846
|
+
use: any[];
|
|
1847
|
+
})["method"][number] : (Opts & {
|
|
1848
|
+
use: any[];
|
|
1849
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
1850
|
+
use: any[];
|
|
1851
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
1852
|
+
use: any[];
|
|
1853
|
+
}, (Opts & {
|
|
1854
|
+
use: any[];
|
|
1855
|
+
})["metadata"] extends {
|
|
1856
|
+
$Infer: {
|
|
1857
|
+
query: infer Query;
|
|
1858
|
+
};
|
|
1859
|
+
} ? Query : (Opts & {
|
|
1860
|
+
use: any[];
|
|
1861
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
1862
|
+
use: any[];
|
|
1863
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
1864
|
+
use: any[];
|
|
1865
|
+
}> & InferHeadersInput<Opts & {
|
|
1866
|
+
use: any[];
|
|
1867
|
+
}> & {
|
|
1868
|
+
asResponse?: boolean;
|
|
1869
|
+
returnHeaders?: boolean;
|
|
1870
|
+
use?: Middleware[];
|
|
1871
|
+
path?: string;
|
|
1872
|
+
} & {
|
|
1873
|
+
asResponse?: AsResponse | undefined;
|
|
1874
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1875
|
+
}] : [((InferBodyInput<Opts & {
|
|
1876
|
+
use: any[];
|
|
1877
|
+
}, (Opts & {
|
|
1878
|
+
use: any[];
|
|
1879
|
+
})["metadata"] extends {
|
|
1880
|
+
$Infer: {
|
|
1881
|
+
body: infer B;
|
|
1882
|
+
};
|
|
1883
|
+
} ? B : (Opts & {
|
|
1884
|
+
use: any[];
|
|
1885
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
1886
|
+
use: any[];
|
|
1887
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
1888
|
+
use: any[];
|
|
1889
|
+
}, (Opts & {
|
|
1890
|
+
use: any[];
|
|
1891
|
+
})["method"] extends any[] ? (Opts & {
|
|
1892
|
+
use: any[];
|
|
1893
|
+
})["method"][number] : (Opts & {
|
|
1894
|
+
use: any[];
|
|
1895
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
1896
|
+
use: any[];
|
|
1897
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
1898
|
+
use: any[];
|
|
1899
|
+
}, (Opts & {
|
|
1900
|
+
use: any[];
|
|
1901
|
+
})["metadata"] extends {
|
|
1902
|
+
$Infer: {
|
|
1903
|
+
query: infer Query;
|
|
1904
|
+
};
|
|
1905
|
+
} ? Query : (Opts & {
|
|
1906
|
+
use: any[];
|
|
1907
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
1908
|
+
use: any[];
|
|
1909
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
1910
|
+
use: any[];
|
|
1911
|
+
}> & InferHeadersInput<Opts & {
|
|
1912
|
+
use: any[];
|
|
1913
|
+
}> & {
|
|
1914
|
+
asResponse?: boolean;
|
|
1915
|
+
returnHeaders?: boolean;
|
|
1916
|
+
use?: Middleware[];
|
|
1917
|
+
path?: string;
|
|
1918
|
+
} & {
|
|
1919
|
+
asResponse?: AsResponse | undefined;
|
|
1920
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1921
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
1922
|
+
headers: Headers;
|
|
1923
|
+
response: Awaited<T_2>;
|
|
1924
|
+
} : Awaited<T_2>>;
|
|
1925
|
+
wrap<T_3>(fn: (context: EndpointContext<Path, Opts & {
|
|
1926
|
+
use: any[];
|
|
1927
|
+
}, {}>, original: (context: EndpointContext<Path, Opts & {
|
|
1928
|
+
use: any[];
|
|
1929
|
+
}, {}>) => Promise<Promise<T_2>>) => T_3): {
|
|
1930
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Opts & {
|
|
1931
|
+
use: any[];
|
|
1932
|
+
}>> extends true ? [InferBodyInput<Opts & {
|
|
1933
|
+
use: any[];
|
|
1934
|
+
}, (Opts & {
|
|
1935
|
+
use: any[];
|
|
1936
|
+
})["metadata"] extends {
|
|
1937
|
+
$Infer: {
|
|
1938
|
+
body: infer B;
|
|
1939
|
+
};
|
|
1940
|
+
} ? B : (Opts & {
|
|
1941
|
+
use: any[];
|
|
1942
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
1943
|
+
use: any[];
|
|
1944
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
1945
|
+
use: any[];
|
|
1946
|
+
}, (Opts & {
|
|
1947
|
+
use: any[];
|
|
1948
|
+
})["method"] extends any[] ? (Opts & {
|
|
1949
|
+
use: any[];
|
|
1950
|
+
})["method"][number] : (Opts & {
|
|
1951
|
+
use: any[];
|
|
1952
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
1953
|
+
use: any[];
|
|
1954
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
1955
|
+
use: any[];
|
|
1956
|
+
}, (Opts & {
|
|
1957
|
+
use: any[];
|
|
1958
|
+
})["metadata"] extends {
|
|
1959
|
+
$Infer: {
|
|
1960
|
+
query: infer Query;
|
|
1961
|
+
};
|
|
1962
|
+
} ? Query : (Opts & {
|
|
1963
|
+
use: any[];
|
|
1964
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
1965
|
+
use: any[];
|
|
1966
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
1967
|
+
use: any[];
|
|
1968
|
+
}> & InferHeadersInput<Opts & {
|
|
1969
|
+
use: any[];
|
|
1970
|
+
}> & {
|
|
1971
|
+
asResponse?: boolean;
|
|
1972
|
+
returnHeaders?: boolean;
|
|
1973
|
+
use?: Middleware[];
|
|
1974
|
+
path?: string;
|
|
1975
|
+
} & {
|
|
1976
|
+
asResponse?: AsResponse | undefined;
|
|
1977
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
1978
|
+
}] : [((InferBodyInput<Opts & {
|
|
1979
|
+
use: any[];
|
|
1980
|
+
}, (Opts & {
|
|
1981
|
+
use: any[];
|
|
1982
|
+
})["metadata"] extends {
|
|
1983
|
+
$Infer: {
|
|
1984
|
+
body: infer B;
|
|
1985
|
+
};
|
|
1986
|
+
} ? B : (Opts & {
|
|
1987
|
+
use: any[];
|
|
1988
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
1989
|
+
use: any[];
|
|
1990
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
1991
|
+
use: any[];
|
|
1992
|
+
}, (Opts & {
|
|
1993
|
+
use: any[];
|
|
1994
|
+
})["method"] extends any[] ? (Opts & {
|
|
1995
|
+
use: any[];
|
|
1996
|
+
})["method"][number] : (Opts & {
|
|
1997
|
+
use: any[];
|
|
1998
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
1999
|
+
use: any[];
|
|
2000
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
2001
|
+
use: any[];
|
|
2002
|
+
}, (Opts & {
|
|
2003
|
+
use: any[];
|
|
2004
|
+
})["metadata"] extends {
|
|
2005
|
+
$Infer: {
|
|
2006
|
+
query: infer Query;
|
|
2007
|
+
};
|
|
2008
|
+
} ? Query : (Opts & {
|
|
2009
|
+
use: any[];
|
|
2010
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2011
|
+
use: any[];
|
|
2012
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
2013
|
+
use: any[];
|
|
2014
|
+
}> & InferHeadersInput<Opts & {
|
|
2015
|
+
use: any[];
|
|
2016
|
+
}> & {
|
|
2017
|
+
asResponse?: boolean;
|
|
2018
|
+
returnHeaders?: boolean;
|
|
2019
|
+
use?: Middleware[];
|
|
2020
|
+
path?: string;
|
|
2021
|
+
} & {
|
|
2022
|
+
asResponse?: AsResponse | undefined;
|
|
2023
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
2024
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
2025
|
+
headers: Headers;
|
|
2026
|
+
response: Awaited<T_3>;
|
|
2027
|
+
} : Awaited<T_3>>;
|
|
2028
|
+
wrap<T_4>(fn: (context: EndpointContext<Path, Opts & {
|
|
2029
|
+
use: any[];
|
|
2030
|
+
}, {}>, original: (context: EndpointContext<Path, Opts & {
|
|
2031
|
+
use: any[];
|
|
2032
|
+
}, {}>) => Promise<Promise<T_3>>) => T_4): {
|
|
2033
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Opts & {
|
|
2034
|
+
use: any[];
|
|
2035
|
+
}>> extends true ? [InferBodyInput<Opts & {
|
|
2036
|
+
use: any[];
|
|
2037
|
+
}, (Opts & {
|
|
2038
|
+
use: any[];
|
|
2039
|
+
})["metadata"] extends {
|
|
2040
|
+
$Infer: {
|
|
2041
|
+
body: infer B;
|
|
2042
|
+
};
|
|
2043
|
+
} ? B : (Opts & {
|
|
2044
|
+
use: any[];
|
|
2045
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2046
|
+
use: any[];
|
|
2047
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
2048
|
+
use: any[];
|
|
2049
|
+
}, (Opts & {
|
|
2050
|
+
use: any[];
|
|
2051
|
+
})["method"] extends any[] ? (Opts & {
|
|
2052
|
+
use: any[];
|
|
2053
|
+
})["method"][number] : (Opts & {
|
|
2054
|
+
use: any[];
|
|
2055
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
2056
|
+
use: any[];
|
|
2057
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
2058
|
+
use: any[];
|
|
2059
|
+
}, (Opts & {
|
|
2060
|
+
use: any[];
|
|
2061
|
+
})["metadata"] extends {
|
|
2062
|
+
$Infer: {
|
|
2063
|
+
query: infer Query;
|
|
2064
|
+
};
|
|
2065
|
+
} ? Query : (Opts & {
|
|
2066
|
+
use: any[];
|
|
2067
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2068
|
+
use: any[];
|
|
2069
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
2070
|
+
use: any[];
|
|
2071
|
+
}> & InferHeadersInput<Opts & {
|
|
2072
|
+
use: any[];
|
|
2073
|
+
}> & {
|
|
2074
|
+
asResponse?: boolean;
|
|
2075
|
+
returnHeaders?: boolean;
|
|
2076
|
+
use?: Middleware[];
|
|
2077
|
+
path?: string;
|
|
2078
|
+
} & {
|
|
2079
|
+
asResponse?: AsResponse | undefined;
|
|
2080
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
2081
|
+
}] : [((InferBodyInput<Opts & {
|
|
2082
|
+
use: any[];
|
|
2083
|
+
}, (Opts & {
|
|
2084
|
+
use: any[];
|
|
2085
|
+
})["metadata"] extends {
|
|
2086
|
+
$Infer: {
|
|
2087
|
+
body: infer B;
|
|
2088
|
+
};
|
|
2089
|
+
} ? B : (Opts & {
|
|
2090
|
+
use: any[];
|
|
2091
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2092
|
+
use: any[];
|
|
2093
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
2094
|
+
use: any[];
|
|
2095
|
+
}, (Opts & {
|
|
2096
|
+
use: any[];
|
|
2097
|
+
})["method"] extends any[] ? (Opts & {
|
|
2098
|
+
use: any[];
|
|
2099
|
+
})["method"][number] : (Opts & {
|
|
2100
|
+
use: any[];
|
|
2101
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
2102
|
+
use: any[];
|
|
2103
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
2104
|
+
use: any[];
|
|
2105
|
+
}, (Opts & {
|
|
2106
|
+
use: any[];
|
|
2107
|
+
})["metadata"] extends {
|
|
2108
|
+
$Infer: {
|
|
2109
|
+
query: infer Query;
|
|
2110
|
+
};
|
|
2111
|
+
} ? Query : (Opts & {
|
|
2112
|
+
use: any[];
|
|
2113
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2114
|
+
use: any[];
|
|
2115
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
2116
|
+
use: any[];
|
|
2117
|
+
}> & InferHeadersInput<Opts & {
|
|
2118
|
+
use: any[];
|
|
2119
|
+
}> & {
|
|
2120
|
+
asResponse?: boolean;
|
|
2121
|
+
returnHeaders?: boolean;
|
|
2122
|
+
use?: Middleware[];
|
|
2123
|
+
path?: string;
|
|
2124
|
+
} & {
|
|
2125
|
+
asResponse?: AsResponse | undefined;
|
|
2126
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
2127
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
2128
|
+
headers: Headers;
|
|
2129
|
+
response: Awaited<T_4>;
|
|
2130
|
+
} : Awaited<T_4>>;
|
|
2131
|
+
wrap<T_5>(fn: (context: EndpointContext<Path, Opts & {
|
|
2132
|
+
use: any[];
|
|
2133
|
+
}, {}>, original: (context: EndpointContext<Path, Opts & {
|
|
2134
|
+
use: any[];
|
|
2135
|
+
}, {}>) => Promise<Promise<T_4>>) => T_5): {
|
|
2136
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Opts & {
|
|
2137
|
+
use: any[];
|
|
2138
|
+
}>> extends true ? [InferBodyInput<Opts & {
|
|
2139
|
+
use: any[];
|
|
2140
|
+
}, (Opts & {
|
|
2141
|
+
use: any[];
|
|
2142
|
+
})["metadata"] extends {
|
|
2143
|
+
$Infer: {
|
|
2144
|
+
body: infer B;
|
|
2145
|
+
};
|
|
2146
|
+
} ? B : (Opts & {
|
|
2147
|
+
use: any[];
|
|
2148
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2149
|
+
use: any[];
|
|
2150
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
2151
|
+
use: any[];
|
|
2152
|
+
}, (Opts & {
|
|
2153
|
+
use: any[];
|
|
2154
|
+
})["method"] extends any[] ? (Opts & {
|
|
2155
|
+
use: any[];
|
|
2156
|
+
})["method"][number] : (Opts & {
|
|
2157
|
+
use: any[];
|
|
2158
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
2159
|
+
use: any[];
|
|
2160
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
2161
|
+
use: any[];
|
|
2162
|
+
}, (Opts & {
|
|
2163
|
+
use: any[];
|
|
2164
|
+
})["metadata"] extends {
|
|
2165
|
+
$Infer: {
|
|
2166
|
+
query: infer Query;
|
|
2167
|
+
};
|
|
2168
|
+
} ? Query : (Opts & {
|
|
2169
|
+
use: any[];
|
|
2170
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2171
|
+
use: any[];
|
|
2172
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
2173
|
+
use: any[];
|
|
2174
|
+
}> & InferHeadersInput<Opts & {
|
|
2175
|
+
use: any[];
|
|
2176
|
+
}> & {
|
|
2177
|
+
asResponse?: boolean;
|
|
2178
|
+
returnHeaders?: boolean;
|
|
2179
|
+
use?: Middleware[];
|
|
2180
|
+
path?: string;
|
|
2181
|
+
} & {
|
|
2182
|
+
asResponse?: AsResponse | undefined;
|
|
2183
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
2184
|
+
}] : [((InferBodyInput<Opts & {
|
|
2185
|
+
use: any[];
|
|
2186
|
+
}, (Opts & {
|
|
2187
|
+
use: any[];
|
|
2188
|
+
})["metadata"] extends {
|
|
2189
|
+
$Infer: {
|
|
2190
|
+
body: infer B;
|
|
2191
|
+
};
|
|
2192
|
+
} ? B : (Opts & {
|
|
2193
|
+
use: any[];
|
|
2194
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2195
|
+
use: any[];
|
|
2196
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
2197
|
+
use: any[];
|
|
2198
|
+
}, (Opts & {
|
|
2199
|
+
use: any[];
|
|
2200
|
+
})["method"] extends any[] ? (Opts & {
|
|
2201
|
+
use: any[];
|
|
2202
|
+
})["method"][number] : (Opts & {
|
|
2203
|
+
use: any[];
|
|
2204
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
2205
|
+
use: any[];
|
|
2206
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
2207
|
+
use: any[];
|
|
2208
|
+
}, (Opts & {
|
|
2209
|
+
use: any[];
|
|
2210
|
+
})["metadata"] extends {
|
|
2211
|
+
$Infer: {
|
|
2212
|
+
query: infer Query;
|
|
2213
|
+
};
|
|
2214
|
+
} ? Query : (Opts & {
|
|
2215
|
+
use: any[];
|
|
2216
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2217
|
+
use: any[];
|
|
2218
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
2219
|
+
use: any[];
|
|
2220
|
+
}> & InferHeadersInput<Opts & {
|
|
2221
|
+
use: any[];
|
|
2222
|
+
}> & {
|
|
2223
|
+
asResponse?: boolean;
|
|
2224
|
+
returnHeaders?: boolean;
|
|
2225
|
+
use?: Middleware[];
|
|
2226
|
+
path?: string;
|
|
2227
|
+
} & {
|
|
2228
|
+
asResponse?: AsResponse | undefined;
|
|
2229
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
2230
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
2231
|
+
headers: Headers;
|
|
2232
|
+
response: Awaited<T_5>;
|
|
2233
|
+
} : Awaited<T_5>>;
|
|
2234
|
+
wrap<T_6>(fn: (context: EndpointContext<Path, Opts & {
|
|
2235
|
+
use: any[];
|
|
2236
|
+
}, {}>, original: (context: EndpointContext<Path, Opts & {
|
|
2237
|
+
use: any[];
|
|
2238
|
+
}, {}>) => Promise<Promise<T_5>>) => T_6): {
|
|
2239
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Opts & {
|
|
2240
|
+
use: any[];
|
|
2241
|
+
}>> extends true ? [InferBodyInput<Opts & {
|
|
2242
|
+
use: any[];
|
|
2243
|
+
}, (Opts & {
|
|
2244
|
+
use: any[];
|
|
2245
|
+
})["metadata"] extends {
|
|
2246
|
+
$Infer: {
|
|
2247
|
+
body: infer B;
|
|
2248
|
+
};
|
|
2249
|
+
} ? B : (Opts & {
|
|
2250
|
+
use: any[];
|
|
2251
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2252
|
+
use: any[];
|
|
2253
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
2254
|
+
use: any[];
|
|
2255
|
+
}, (Opts & {
|
|
2256
|
+
use: any[];
|
|
2257
|
+
})["method"] extends any[] ? (Opts & {
|
|
2258
|
+
use: any[];
|
|
2259
|
+
})["method"][number] : (Opts & {
|
|
2260
|
+
use: any[];
|
|
2261
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
2262
|
+
use: any[];
|
|
2263
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
2264
|
+
use: any[];
|
|
2265
|
+
}, (Opts & {
|
|
2266
|
+
use: any[];
|
|
2267
|
+
})["metadata"] extends {
|
|
2268
|
+
$Infer: {
|
|
2269
|
+
query: infer Query;
|
|
2270
|
+
};
|
|
2271
|
+
} ? Query : (Opts & {
|
|
2272
|
+
use: any[];
|
|
2273
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2274
|
+
use: any[];
|
|
2275
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
2276
|
+
use: any[];
|
|
2277
|
+
}> & InferHeadersInput<Opts & {
|
|
2278
|
+
use: any[];
|
|
2279
|
+
}> & {
|
|
2280
|
+
asResponse?: boolean;
|
|
2281
|
+
returnHeaders?: boolean;
|
|
2282
|
+
use?: Middleware[];
|
|
2283
|
+
path?: string;
|
|
2284
|
+
} & {
|
|
2285
|
+
asResponse?: AsResponse | undefined;
|
|
2286
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
2287
|
+
}] : [((InferBodyInput<Opts & {
|
|
2288
|
+
use: any[];
|
|
2289
|
+
}, (Opts & {
|
|
2290
|
+
use: any[];
|
|
2291
|
+
})["metadata"] extends {
|
|
2292
|
+
$Infer: {
|
|
2293
|
+
body: infer B;
|
|
2294
|
+
};
|
|
2295
|
+
} ? B : (Opts & {
|
|
2296
|
+
use: any[];
|
|
2297
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2298
|
+
use: any[];
|
|
2299
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
2300
|
+
use: any[];
|
|
2301
|
+
}, (Opts & {
|
|
2302
|
+
use: any[];
|
|
2303
|
+
})["method"] extends any[] ? (Opts & {
|
|
2304
|
+
use: any[];
|
|
2305
|
+
})["method"][number] : (Opts & {
|
|
2306
|
+
use: any[];
|
|
2307
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
2308
|
+
use: any[];
|
|
2309
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
2310
|
+
use: any[];
|
|
2311
|
+
}, (Opts & {
|
|
2312
|
+
use: any[];
|
|
2313
|
+
})["metadata"] extends {
|
|
2314
|
+
$Infer: {
|
|
2315
|
+
query: infer Query;
|
|
2316
|
+
};
|
|
2317
|
+
} ? Query : (Opts & {
|
|
2318
|
+
use: any[];
|
|
2319
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2320
|
+
use: any[];
|
|
2321
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
2322
|
+
use: any[];
|
|
2323
|
+
}> & InferHeadersInput<Opts & {
|
|
2324
|
+
use: any[];
|
|
2325
|
+
}> & {
|
|
2326
|
+
asResponse?: boolean;
|
|
2327
|
+
returnHeaders?: boolean;
|
|
2328
|
+
use?: Middleware[];
|
|
2329
|
+
path?: string;
|
|
2330
|
+
} & {
|
|
2331
|
+
asResponse?: AsResponse | undefined;
|
|
2332
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
2333
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
2334
|
+
headers: Headers;
|
|
2335
|
+
response: Awaited<T_6>;
|
|
2336
|
+
} : Awaited<T_6>>;
|
|
2337
|
+
wrap<T_7>(fn: (context: EndpointContext<Path, Opts & {
|
|
2338
|
+
use: any[];
|
|
2339
|
+
}, {}>, original: (context: EndpointContext<Path, Opts & {
|
|
2340
|
+
use: any[];
|
|
2341
|
+
}, {}>) => Promise<Promise<T_6>>) => T_7): {
|
|
2342
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Opts & {
|
|
2343
|
+
use: any[];
|
|
2344
|
+
}>> extends true ? [InferBodyInput<Opts & {
|
|
2345
|
+
use: any[];
|
|
2346
|
+
}, (Opts & {
|
|
2347
|
+
use: any[];
|
|
2348
|
+
})["metadata"] extends {
|
|
2349
|
+
$Infer: {
|
|
2350
|
+
body: infer B;
|
|
2351
|
+
};
|
|
2352
|
+
} ? B : (Opts & {
|
|
2353
|
+
use: any[];
|
|
2354
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2355
|
+
use: any[];
|
|
2356
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
2357
|
+
use: any[];
|
|
2358
|
+
}, (Opts & {
|
|
2359
|
+
use: any[];
|
|
2360
|
+
})["method"] extends any[] ? (Opts & {
|
|
2361
|
+
use: any[];
|
|
2362
|
+
})["method"][number] : (Opts & {
|
|
2363
|
+
use: any[];
|
|
2364
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
2365
|
+
use: any[];
|
|
2366
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
2367
|
+
use: any[];
|
|
2368
|
+
}, (Opts & {
|
|
2369
|
+
use: any[];
|
|
2370
|
+
})["metadata"] extends {
|
|
2371
|
+
$Infer: {
|
|
2372
|
+
query: infer Query;
|
|
2373
|
+
};
|
|
2374
|
+
} ? Query : (Opts & {
|
|
2375
|
+
use: any[];
|
|
2376
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2377
|
+
use: any[];
|
|
2378
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
2379
|
+
use: any[];
|
|
2380
|
+
}> & InferHeadersInput<Opts & {
|
|
2381
|
+
use: any[];
|
|
2382
|
+
}> & {
|
|
2383
|
+
asResponse?: boolean;
|
|
2384
|
+
returnHeaders?: boolean;
|
|
2385
|
+
use?: Middleware[];
|
|
2386
|
+
path?: string;
|
|
2387
|
+
} & {
|
|
2388
|
+
asResponse?: AsResponse | undefined;
|
|
2389
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
2390
|
+
}] : [((InferBodyInput<Opts & {
|
|
2391
|
+
use: any[];
|
|
2392
|
+
}, (Opts & {
|
|
2393
|
+
use: any[];
|
|
2394
|
+
})["metadata"] extends {
|
|
2395
|
+
$Infer: {
|
|
2396
|
+
body: infer B;
|
|
2397
|
+
};
|
|
2398
|
+
} ? B : (Opts & {
|
|
2399
|
+
use: any[];
|
|
2400
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2401
|
+
use: any[];
|
|
2402
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
2403
|
+
use: any[];
|
|
2404
|
+
}, (Opts & {
|
|
2405
|
+
use: any[];
|
|
2406
|
+
})["method"] extends any[] ? (Opts & {
|
|
2407
|
+
use: any[];
|
|
2408
|
+
})["method"][number] : (Opts & {
|
|
2409
|
+
use: any[];
|
|
2410
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
2411
|
+
use: any[];
|
|
2412
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
2413
|
+
use: any[];
|
|
2414
|
+
}, (Opts & {
|
|
2415
|
+
use: any[];
|
|
2416
|
+
})["metadata"] extends {
|
|
2417
|
+
$Infer: {
|
|
2418
|
+
query: infer Query;
|
|
2419
|
+
};
|
|
2420
|
+
} ? Query : (Opts & {
|
|
2421
|
+
use: any[];
|
|
2422
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2423
|
+
use: any[];
|
|
2424
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
2425
|
+
use: any[];
|
|
2426
|
+
}> & InferHeadersInput<Opts & {
|
|
2427
|
+
use: any[];
|
|
2428
|
+
}> & {
|
|
2429
|
+
asResponse?: boolean;
|
|
2430
|
+
returnHeaders?: boolean;
|
|
2431
|
+
use?: Middleware[];
|
|
2432
|
+
path?: string;
|
|
2433
|
+
} & {
|
|
2434
|
+
asResponse?: AsResponse | undefined;
|
|
2435
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
2436
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
2437
|
+
headers: Headers;
|
|
2438
|
+
response: Awaited<T_7>;
|
|
2439
|
+
} : Awaited<T_7>>;
|
|
2440
|
+
wrap<T_8>(fn: (context: EndpointContext<Path, Opts & {
|
|
2441
|
+
use: any[];
|
|
2442
|
+
}, {}>, original: (context: EndpointContext<Path, Opts & {
|
|
2443
|
+
use: any[];
|
|
2444
|
+
}, {}>) => Promise<Promise<T_7>>) => T_8): {
|
|
2445
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Opts & {
|
|
2446
|
+
use: any[];
|
|
2447
|
+
}>> extends true ? [InferBodyInput<Opts & {
|
|
2448
|
+
use: any[];
|
|
2449
|
+
}, (Opts & {
|
|
2450
|
+
use: any[];
|
|
2451
|
+
})["metadata"] extends {
|
|
2452
|
+
$Infer: {
|
|
2453
|
+
body: infer B;
|
|
2454
|
+
};
|
|
2455
|
+
} ? B : (Opts & {
|
|
2456
|
+
use: any[];
|
|
2457
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2458
|
+
use: any[];
|
|
2459
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
2460
|
+
use: any[];
|
|
2461
|
+
}, (Opts & {
|
|
2462
|
+
use: any[];
|
|
2463
|
+
})["method"] extends any[] ? (Opts & {
|
|
2464
|
+
use: any[];
|
|
2465
|
+
})["method"][number] : (Opts & {
|
|
2466
|
+
use: any[];
|
|
2467
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
2468
|
+
use: any[];
|
|
2469
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
2470
|
+
use: any[];
|
|
2471
|
+
}, (Opts & {
|
|
2472
|
+
use: any[];
|
|
2473
|
+
})["metadata"] extends {
|
|
2474
|
+
$Infer: {
|
|
2475
|
+
query: infer Query;
|
|
2476
|
+
};
|
|
2477
|
+
} ? Query : (Opts & {
|
|
2478
|
+
use: any[];
|
|
2479
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2480
|
+
use: any[];
|
|
2481
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
2482
|
+
use: any[];
|
|
2483
|
+
}> & InferHeadersInput<Opts & {
|
|
2484
|
+
use: any[];
|
|
2485
|
+
}> & {
|
|
2486
|
+
asResponse?: boolean;
|
|
2487
|
+
returnHeaders?: boolean;
|
|
2488
|
+
use?: Middleware[];
|
|
2489
|
+
path?: string;
|
|
2490
|
+
} & {
|
|
2491
|
+
asResponse?: AsResponse | undefined;
|
|
2492
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
2493
|
+
}] : [((InferBodyInput<Opts & {
|
|
2494
|
+
use: any[];
|
|
2495
|
+
}, (Opts & {
|
|
2496
|
+
use: any[];
|
|
2497
|
+
})["metadata"] extends {
|
|
2498
|
+
$Infer: {
|
|
2499
|
+
body: infer B;
|
|
2500
|
+
};
|
|
2501
|
+
} ? B : (Opts & {
|
|
2502
|
+
use: any[];
|
|
2503
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2504
|
+
use: any[];
|
|
2505
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
2506
|
+
use: any[];
|
|
2507
|
+
}, (Opts & {
|
|
2508
|
+
use: any[];
|
|
2509
|
+
})["method"] extends any[] ? (Opts & {
|
|
2510
|
+
use: any[];
|
|
2511
|
+
})["method"][number] : (Opts & {
|
|
2512
|
+
use: any[];
|
|
2513
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
2514
|
+
use: any[];
|
|
2515
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
2516
|
+
use: any[];
|
|
2517
|
+
}, (Opts & {
|
|
2518
|
+
use: any[];
|
|
2519
|
+
})["metadata"] extends {
|
|
2520
|
+
$Infer: {
|
|
2521
|
+
query: infer Query;
|
|
2522
|
+
};
|
|
2523
|
+
} ? Query : (Opts & {
|
|
2524
|
+
use: any[];
|
|
2525
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2526
|
+
use: any[];
|
|
2527
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
2528
|
+
use: any[];
|
|
2529
|
+
}> & InferHeadersInput<Opts & {
|
|
2530
|
+
use: any[];
|
|
2531
|
+
}> & {
|
|
2532
|
+
asResponse?: boolean;
|
|
2533
|
+
returnHeaders?: boolean;
|
|
2534
|
+
use?: Middleware[];
|
|
2535
|
+
path?: string;
|
|
2536
|
+
} & {
|
|
2537
|
+
asResponse?: AsResponse | undefined;
|
|
2538
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
2539
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
2540
|
+
headers: Headers;
|
|
2541
|
+
response: Awaited<T_8>;
|
|
2542
|
+
} : Awaited<T_8>>;
|
|
2543
|
+
wrap<T_9>(fn: (context: EndpointContext<Path, Opts & {
|
|
2544
|
+
use: any[];
|
|
2545
|
+
}, {}>, original: (context: EndpointContext<Path, Opts & {
|
|
2546
|
+
use: any[];
|
|
2547
|
+
}, {}>) => Promise<Promise<T_8>>) => T_9): {
|
|
2548
|
+
<AsResponse extends boolean = false, ReturnHeaders extends boolean = false>(...inputCtx: HasRequiredKeys<InputContext<Path, Opts & {
|
|
2549
|
+
use: any[];
|
|
2550
|
+
}>> extends true ? [InferBodyInput<Opts & {
|
|
2551
|
+
use: any[];
|
|
2552
|
+
}, (Opts & {
|
|
2553
|
+
use: any[];
|
|
2554
|
+
})["metadata"] extends {
|
|
2555
|
+
$Infer: {
|
|
2556
|
+
body: infer B;
|
|
2557
|
+
};
|
|
2558
|
+
} ? B : (Opts & {
|
|
2559
|
+
use: any[];
|
|
2560
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2561
|
+
use: any[];
|
|
2562
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
2563
|
+
use: any[];
|
|
2564
|
+
}, (Opts & {
|
|
2565
|
+
use: any[];
|
|
2566
|
+
})["method"] extends any[] ? (Opts & {
|
|
2567
|
+
use: any[];
|
|
2568
|
+
})["method"][number] : (Opts & {
|
|
2569
|
+
use: any[];
|
|
2570
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
2571
|
+
use: any[];
|
|
2572
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
2573
|
+
use: any[];
|
|
2574
|
+
}, (Opts & {
|
|
2575
|
+
use: any[];
|
|
2576
|
+
})["metadata"] extends {
|
|
2577
|
+
$Infer: {
|
|
2578
|
+
query: infer Query;
|
|
2579
|
+
};
|
|
2580
|
+
} ? Query : (Opts & {
|
|
2581
|
+
use: any[];
|
|
2582
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2583
|
+
use: any[];
|
|
2584
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
2585
|
+
use: any[];
|
|
2586
|
+
}> & InferHeadersInput<Opts & {
|
|
2587
|
+
use: any[];
|
|
2588
|
+
}> & {
|
|
2589
|
+
asResponse?: boolean;
|
|
2590
|
+
returnHeaders?: boolean;
|
|
2591
|
+
use?: Middleware[];
|
|
2592
|
+
path?: string;
|
|
2593
|
+
} & {
|
|
2594
|
+
asResponse?: AsResponse | undefined;
|
|
2595
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
2596
|
+
}] : [((InferBodyInput<Opts & {
|
|
2597
|
+
use: any[];
|
|
2598
|
+
}, (Opts & {
|
|
2599
|
+
use: any[];
|
|
2600
|
+
})["metadata"] extends {
|
|
2601
|
+
$Infer: {
|
|
2602
|
+
body: infer B;
|
|
2603
|
+
};
|
|
2604
|
+
} ? B : (Opts & {
|
|
2605
|
+
use: any[];
|
|
2606
|
+
})["body"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2607
|
+
use: any[];
|
|
2608
|
+
})["body"]> : undefined> & InferInputMethod<Opts & {
|
|
2609
|
+
use: any[];
|
|
2610
|
+
}, (Opts & {
|
|
2611
|
+
use: any[];
|
|
2612
|
+
})["method"] extends any[] ? (Opts & {
|
|
2613
|
+
use: any[];
|
|
2614
|
+
})["method"][number] : (Opts & {
|
|
2615
|
+
use: any[];
|
|
2616
|
+
})["method"] extends "*" ? HTTPMethod : (Opts & {
|
|
2617
|
+
use: any[];
|
|
2618
|
+
})["method"] | undefined> & InferQueryInput<Opts & {
|
|
2619
|
+
use: any[];
|
|
2620
|
+
}, (Opts & {
|
|
2621
|
+
use: any[];
|
|
2622
|
+
})["metadata"] extends {
|
|
2623
|
+
$Infer: {
|
|
2624
|
+
query: infer Query;
|
|
2625
|
+
};
|
|
2626
|
+
} ? Query : (Opts & {
|
|
2627
|
+
use: any[];
|
|
2628
|
+
})["query"] extends StandardSchemaV1<unknown, unknown> ? StandardSchemaV1.InferInput<(Opts & {
|
|
2629
|
+
use: any[];
|
|
2630
|
+
})["query"]> : Record<string, any> | undefined> & InferParamInput<Path> & InferRequestInput<Opts & {
|
|
2631
|
+
use: any[];
|
|
2632
|
+
}> & InferHeadersInput<Opts & {
|
|
2633
|
+
use: any[];
|
|
2634
|
+
}> & {
|
|
2635
|
+
asResponse?: boolean;
|
|
2636
|
+
returnHeaders?: boolean;
|
|
2637
|
+
use?: Middleware[];
|
|
2638
|
+
path?: string;
|
|
2639
|
+
} & {
|
|
2640
|
+
asResponse?: AsResponse | undefined;
|
|
2641
|
+
returnHeaders?: ReturnHeaders | undefined;
|
|
2642
|
+
}) | undefined)?]): Promise<AsResponse extends true ? Response : ReturnHeaders extends true ? {
|
|
2643
|
+
headers: Headers;
|
|
2644
|
+
response: Awaited<T_9>;
|
|
2645
|
+
} : Awaited<T_9>>;
|
|
2646
|
+
wrap<T_10>(fn: (context: EndpointContext<Path, Opts & {
|
|
2647
|
+
use: any[];
|
|
2648
|
+
}, {}>, original: (context: EndpointContext<Path, Opts & {
|
|
2649
|
+
use: any[];
|
|
2650
|
+
}, {}>) => Promise<Promise<T_9>>) => T_10): /*elided*/ any;
|
|
2651
|
+
options: Opts & {
|
|
2652
|
+
use: any[];
|
|
2653
|
+
};
|
|
2654
|
+
path: Path;
|
|
2655
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Opts & {
|
|
2656
|
+
use: any[];
|
|
2657
|
+
}, {}>) => Promise<T_9>;
|
|
2658
|
+
};
|
|
2659
|
+
options: Opts & {
|
|
2660
|
+
use: any[];
|
|
2661
|
+
};
|
|
2662
|
+
path: Path;
|
|
2663
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Opts & {
|
|
2664
|
+
use: any[];
|
|
2665
|
+
}, {}>) => Promise<T_8>;
|
|
2666
|
+
};
|
|
2667
|
+
options: Opts & {
|
|
2668
|
+
use: any[];
|
|
2669
|
+
};
|
|
2670
|
+
path: Path;
|
|
2671
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Opts & {
|
|
2672
|
+
use: any[];
|
|
2673
|
+
}, {}>) => Promise<T_7>;
|
|
2674
|
+
};
|
|
2675
|
+
options: Opts & {
|
|
2676
|
+
use: any[];
|
|
2677
|
+
};
|
|
2678
|
+
path: Path;
|
|
2679
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Opts & {
|
|
2680
|
+
use: any[];
|
|
2681
|
+
}, {}>) => Promise<T_6>;
|
|
2682
|
+
};
|
|
2683
|
+
options: Opts & {
|
|
2684
|
+
use: any[];
|
|
2685
|
+
};
|
|
2686
|
+
path: Path;
|
|
2687
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Opts & {
|
|
2688
|
+
use: any[];
|
|
2689
|
+
}, {}>) => Promise<T_5>;
|
|
2690
|
+
};
|
|
2691
|
+
options: Opts & {
|
|
2692
|
+
use: any[];
|
|
2693
|
+
};
|
|
2694
|
+
path: Path;
|
|
2695
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Opts & {
|
|
2696
|
+
use: any[];
|
|
2697
|
+
}, {}>) => Promise<T_4>;
|
|
2698
|
+
};
|
|
2699
|
+
options: Opts & {
|
|
2700
|
+
use: any[];
|
|
2701
|
+
};
|
|
2702
|
+
path: Path;
|
|
2703
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Opts & {
|
|
2704
|
+
use: any[];
|
|
2705
|
+
}, {}>) => Promise<T_3>;
|
|
2706
|
+
};
|
|
2707
|
+
options: Opts & {
|
|
2708
|
+
use: any[];
|
|
2709
|
+
};
|
|
2710
|
+
path: Path;
|
|
2711
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Opts & {
|
|
2712
|
+
use: any[];
|
|
2713
|
+
}, {}>) => Promise<T_2>;
|
|
2714
|
+
};
|
|
2715
|
+
options: Opts & {
|
|
2716
|
+
use: any[];
|
|
2717
|
+
};
|
|
2718
|
+
path: Path;
|
|
2719
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Opts & {
|
|
2720
|
+
use: any[];
|
|
2721
|
+
}, {}>) => Promise<T_1>;
|
|
2722
|
+
};
|
|
2723
|
+
options: Opts & {
|
|
2724
|
+
use: any[];
|
|
2725
|
+
};
|
|
2726
|
+
path: Path;
|
|
2727
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Opts & {
|
|
2728
|
+
use: any[];
|
|
2729
|
+
}, {}>) => Promise<T>;
|
|
2730
|
+
};
|
|
2731
|
+
options: Opts & {
|
|
2732
|
+
use: any[];
|
|
2733
|
+
};
|
|
2734
|
+
path: Path;
|
|
2735
|
+
[originalHandlerSymbol]: (context: EndpointContext<Path, Opts & {
|
|
2736
|
+
use: any[];
|
|
2737
|
+
}, {}>) => R;
|
|
2738
|
+
};
|
|
2739
|
+
};
|
|
2740
|
+
type Endpoint<Path extends string = string, Options extends EndpointOptions = EndpointOptions, Handler extends (inputCtx: any) => Promise<any> = (inputCtx: any) => Promise<any>> = Handler & {
|
|
2741
|
+
options: Options;
|
|
2742
|
+
path: Path;
|
|
2743
|
+
};
|
|
2744
|
+
|
|
2745
|
+
interface RouterConfig {
|
|
2746
|
+
throwError?: boolean;
|
|
2747
|
+
onError?: (e: unknown) => void | Promise<void> | Response | Promise<Response>;
|
|
2748
|
+
basePath?: string;
|
|
2749
|
+
routerMiddleware?: Array<{
|
|
2750
|
+
path: string;
|
|
2751
|
+
middleware: Middleware;
|
|
2752
|
+
}>;
|
|
2753
|
+
/**
|
|
2754
|
+
* additional Context that needs to passed to endpoints
|
|
2755
|
+
*
|
|
2756
|
+
* this will be available on `ctx.context` on endpoints
|
|
2757
|
+
*/
|
|
2758
|
+
routerContext?: Record<string, any>;
|
|
2759
|
+
/**
|
|
2760
|
+
* A callback to run before any response
|
|
2761
|
+
*/
|
|
2762
|
+
onResponse?: (res: Response) => any | Promise<any>;
|
|
2763
|
+
/**
|
|
2764
|
+
* A callback to run before any request
|
|
2765
|
+
*/
|
|
2766
|
+
onRequest?: (req: Request) => any | Promise<any>;
|
|
2767
|
+
/**
|
|
2768
|
+
* Open API route configuration
|
|
2769
|
+
*/
|
|
2770
|
+
openapi?: {
|
|
2771
|
+
/**
|
|
2772
|
+
* Disable openapi route
|
|
2773
|
+
*
|
|
2774
|
+
* @default false
|
|
2775
|
+
*/
|
|
2776
|
+
disabled?: boolean;
|
|
2777
|
+
/**
|
|
2778
|
+
* A path to display open api using scalar
|
|
2779
|
+
*
|
|
2780
|
+
* @default "/api/reference"
|
|
2781
|
+
*/
|
|
2782
|
+
path?: string;
|
|
2783
|
+
/**
|
|
2784
|
+
* Scalar Configuration
|
|
2785
|
+
*/
|
|
2786
|
+
scalar?: {
|
|
2787
|
+
/**
|
|
2788
|
+
* Title
|
|
2789
|
+
* @default "Open API Reference"
|
|
2790
|
+
*/
|
|
2791
|
+
title?: string;
|
|
2792
|
+
/**
|
|
2793
|
+
* Description
|
|
2794
|
+
*
|
|
2795
|
+
* @default "Better Call Open API Reference"
|
|
2796
|
+
*/
|
|
2797
|
+
description?: string;
|
|
2798
|
+
/**
|
|
2799
|
+
* Logo URL
|
|
2800
|
+
*/
|
|
2801
|
+
logo?: string;
|
|
2802
|
+
/**
|
|
2803
|
+
* Scalar theme
|
|
2804
|
+
* @default "saturn"
|
|
2805
|
+
*/
|
|
2806
|
+
theme?: string;
|
|
2807
|
+
};
|
|
2808
|
+
};
|
|
2809
|
+
}
|
|
2810
|
+
declare const createRouter: <E extends Record<string, Endpoint>, Config extends RouterConfig>(endpoints: E, config?: Config) => {
|
|
2811
|
+
handler: (request: Request) => Promise<Response>;
|
|
2812
|
+
endpoints: E;
|
|
2813
|
+
};
|
|
2814
|
+
type Router = ReturnType<typeof createRouter>;
|
|
2815
|
+
|
|
2816
|
+
export { type MergeObject as $, APIError as A, type InferParam as B, type CookiePrefixOptions as C, type InferParamInput as D, type EndpointOptions as E, type InferRequest as F, type InferRequestInput as G, type HTTPMethod as H, type InferBodyInput as I, type InferHeaders as J, type InferHeadersInput as K, type InferUse as L, type MiddlewareOptions as M, type InferMiddlewareBody as N, type OpenAPISchemaType as O, type Path as P, type InferMiddlewareQuery as Q, type RouterConfig as R, type Status as S, type InputContext as T, createInternalContext as U, type RequiredKeysOf as V, type HasRequiredKeys as W, type Prettify as X, type IsEmptyObject as Y, type UnionToIntersection as Z, _statusCode as _, type EndpointContext as a, type InferParamPath as a0, type InferParamWildCard as a1, StandardSchemaV1 as a2, type Endpoint as b, createEndpoint as c, type MiddlewareResponse as d, type MiddlewareContext as e, createMiddleware as f, type MiddlewareInputContext as g, type Middleware as h, createRouter as i, type Router as j, type CookieOptions as k, getCookieKey as l, serializeSignedCookie as m, type OpenAPIParameter as n, generator as o, parseCookies as p, getHTML as q, hideInternalStackFrames as r, serializeCookie as s, makeErrorForHideStackFrame as t, type Method as u, type InferBody as v, type InferQueryInput as w, type InferQuery as x, type InferMethod as y, type InferInputMethod as z };
|