better-call 1.0.21 → 1.0.23

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.
@@ -0,0 +1,1187 @@
1
+ //#region src/helper.d.ts
2
+ type RequiredKeysOf<BaseType extends object> = Exclude<{ [Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]> ? Key : never }[keyof BaseType], undefined>;
3
+ type HasRequiredKeys<BaseType extends object> = RequiredKeysOf<BaseType> extends never ? false : true;
4
+ type Prettify<T> = { [K in keyof T]: T[K] } & {};
5
+ type IsEmptyObject<T> = keyof T extends never ? true : false;
6
+ type UnionToIntersection<Union> = (Union extends unknown ? (distributedUnion: Union) => void : never) extends ((mergedIntersection: infer Intersection) => void) ? Intersection & Union : never;
7
+ type MergeObject<T extends Record<string, any> | never, S extends Record<string, any> | never> = T extends never ? S : S extends never ? T : T & S;
8
+ type InferParamPath<Path> = Path extends `${infer _Start}:${infer Param}/${infer Rest}` ? { [K in Param | keyof InferParamPath<Rest>]: string } : Path extends `${infer _Start}:${infer Param}` ? { [K in Param]: string } : Path extends `${infer _Start}/${infer Rest}` ? InferParamPath<Rest> : {};
9
+ type InferParamWildCard<Path> = Path extends `${infer _Start}/*:${infer Param}/${infer Rest}` | `${infer _Start}/**:${infer Param}/${infer Rest}` ? { [K in Param | keyof InferParamPath<Rest>]: string } : Path extends `${infer _Start}/*` ? { [K in "_"]: string } : Path extends `${infer _Start}/${infer Rest}` ? InferParamWildCard<Rest> : {};
10
+ //#endregion
11
+ //#region src/error.d.ts
12
+ /**
13
+ * Hide internal stack frames from the error stack trace.
14
+ */
15
+ declare function hideInternalStackFrames(stack: string): string;
16
+ /**
17
+ * Creates a custom error class that hides stack frames.
18
+ */
19
+ declare function makeErrorForHideStackFrame<B extends new (...args: any[]) => Error>(Base: B, clazz: any): {
20
+ new (...args: ConstructorParameters<B>): InstanceType<B> & {
21
+ errorStack: string | undefined;
22
+ };
23
+ };
24
+ declare const _statusCode: {
25
+ OK: number;
26
+ CREATED: number;
27
+ ACCEPTED: number;
28
+ NO_CONTENT: number;
29
+ MULTIPLE_CHOICES: number;
30
+ MOVED_PERMANENTLY: number;
31
+ FOUND: number;
32
+ SEE_OTHER: number;
33
+ NOT_MODIFIED: number;
34
+ TEMPORARY_REDIRECT: number;
35
+ BAD_REQUEST: number;
36
+ UNAUTHORIZED: number;
37
+ PAYMENT_REQUIRED: number;
38
+ FORBIDDEN: number;
39
+ NOT_FOUND: number;
40
+ METHOD_NOT_ALLOWED: number;
41
+ NOT_ACCEPTABLE: number;
42
+ PROXY_AUTHENTICATION_REQUIRED: number;
43
+ REQUEST_TIMEOUT: number;
44
+ CONFLICT: number;
45
+ GONE: number;
46
+ LENGTH_REQUIRED: number;
47
+ PRECONDITION_FAILED: number;
48
+ PAYLOAD_TOO_LARGE: number;
49
+ URI_TOO_LONG: number;
50
+ UNSUPPORTED_MEDIA_TYPE: number;
51
+ RANGE_NOT_SATISFIABLE: number;
52
+ EXPECTATION_FAILED: number;
53
+ "I'M_A_TEAPOT": number;
54
+ MISDIRECTED_REQUEST: number;
55
+ UNPROCESSABLE_ENTITY: number;
56
+ LOCKED: number;
57
+ FAILED_DEPENDENCY: number;
58
+ TOO_EARLY: number;
59
+ UPGRADE_REQUIRED: number;
60
+ PRECONDITION_REQUIRED: number;
61
+ TOO_MANY_REQUESTS: number;
62
+ REQUEST_HEADER_FIELDS_TOO_LARGE: number;
63
+ UNAVAILABLE_FOR_LEGAL_REASONS: number;
64
+ INTERNAL_SERVER_ERROR: number;
65
+ NOT_IMPLEMENTED: number;
66
+ BAD_GATEWAY: number;
67
+ SERVICE_UNAVAILABLE: number;
68
+ GATEWAY_TIMEOUT: number;
69
+ HTTP_VERSION_NOT_SUPPORTED: number;
70
+ VARIANT_ALSO_NEGOTIATES: number;
71
+ INSUFFICIENT_STORAGE: number;
72
+ LOOP_DETECTED: number;
73
+ NOT_EXTENDED: number;
74
+ NETWORK_AUTHENTICATION_REQUIRED: number;
75
+ };
76
+ 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;
77
+ declare class InternalAPIError extends Error {
78
+ status: keyof typeof _statusCode | Status;
79
+ body: ({
80
+ message?: string;
81
+ code?: string;
82
+ cause?: unknown;
83
+ } & Record<string, any>) | undefined;
84
+ headers: HeadersInit;
85
+ statusCode: number;
86
+ constructor(status?: keyof typeof _statusCode | Status, body?: ({
87
+ message?: string;
88
+ code?: string;
89
+ cause?: unknown;
90
+ } & Record<string, any>) | undefined, headers?: HeadersInit, statusCode?: number);
91
+ }
92
+ type APIError = InstanceType<typeof InternalAPIError>;
93
+ declare const APIError: new (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" | Status | undefined, body?: ({
94
+ message?: string;
95
+ code?: string;
96
+ cause?: unknown;
97
+ } & Record<string, any>) | undefined, headers?: HeadersInit | undefined, statusCode?: number | undefined) => InternalAPIError & {
98
+ errorStack: string | undefined;
99
+ };
100
+ //#endregion
101
+ //#region src/cookies.d.ts
102
+ type CookiePrefixOptions = "host" | "secure";
103
+ type CookieOptions = {
104
+ /**
105
+ * Domain of the cookie
106
+ *
107
+ * The Domain attribute specifies which server can receive a cookie. If specified, cookies are
108
+ * available on the specified server and its subdomains. If the it is not
109
+ * specified, the cookies are available on the server that sets it but not on
110
+ * its subdomains.
111
+ *
112
+ * @example
113
+ * `domain: "example.com"`
114
+ */
115
+ domain?: string;
116
+ /**
117
+ * A lifetime of a cookie. Permanent cookies are deleted after the date specified in the
118
+ * Expires attribute:
119
+ *
120
+ * Expires has been available for longer than Max-Age, however Max-Age is less error-prone, and
121
+ * takes precedence when both are set. The rationale behind this is that when you set an
122
+ * Expires date and time, they're relative to the client the cookie is being set on. If the
123
+ * server is set to a different time, this could cause errors
124
+ */
125
+ expires?: Date;
126
+ /**
127
+ * Forbids JavaScript from accessing the cookie, for example, through the Document.cookie
128
+ * property. Note that a cookie that has been created with HttpOnly will still be sent with
129
+ * JavaScript-initiated requests, for example, when calling XMLHttpRequest.send() or fetch().
130
+ * This mitigates attacks against cross-site scripting
131
+ */
132
+ httpOnly?: boolean;
133
+ /**
134
+ * Indicates the number of seconds until the cookie expires. A zero or negative number will
135
+ * expire the cookie immediately. If both Expires and Max-Age are set, Max-Age has precedence.
136
+ *
137
+ * @example 604800 - 7 days
138
+ */
139
+ maxAge?: number;
140
+ /**
141
+ * Indicates the path that must exist in the requested URL for the browser to send the Cookie
142
+ * header.
143
+ *
144
+ * @example
145
+ * "/docs"
146
+ * // -> the request paths /docs, /docs/, /docs/Web/, and /docs/Web/HTTP will all match. the request paths /, /fr/docs will not match.
147
+ */
148
+ path?: string;
149
+ /**
150
+ * Indicates that the cookie is sent to the server only when a request is made with the https:
151
+ * scheme (except on localhost), and therefore, is more resistant to man-in-the-middle attacks.
152
+ */
153
+ secure?: boolean;
154
+ /**
155
+ * Controls whether or not a cookie is sent with cross-site requests, providing some protection
156
+ * against cross-site request forgery attacks (CSRF).
157
+ *
158
+ * Strict - Means that the browser sends the cookie only for same-site requests, that is,
159
+ * requests originating from the same site that set the cookie. If a request originates from a
160
+ * different domain or scheme (even with the same domain), no cookies with the SameSite=Strict
161
+ * attribute are sent.
162
+ *
163
+ * Lax - Means that the cookie is not sent on cross-site requests, such as on requests to load
164
+ * images or frames, but is sent when a user is navigating to the origin site from an external
165
+ * site (for example, when following a link). This is the default behavior if the SameSite
166
+ * attribute is not specified.
167
+ *
168
+ * None - Means that the browser sends the cookie with both cross-site and same-site requests.
169
+ * The Secure attribute must also be set when setting this value.
170
+ */
171
+ sameSite?: "Strict" | "Lax" | "None" | "strict" | "lax" | "none";
172
+ /**
173
+ * Indicates that the cookie should be stored using partitioned storage. Note that if this is
174
+ * set, the Secure directive must also be set.
175
+ *
176
+ * @see https://developer.mozilla.org/en-US/docs/Web/Privacy/Privacy_sandbox/Partitioned_cookies
177
+ */
178
+ partitioned?: boolean;
179
+ /**
180
+ * Cooke Prefix
181
+ *
182
+ * - secure: `__Secure-` -> `__Secure-cookie-name`
183
+ * - host: `__Host-` -> `__Host-cookie-name`
184
+ *
185
+ * `secure` must be set to true to use prefixes
186
+ */
187
+ prefix?: CookiePrefixOptions;
188
+ };
189
+ declare const getCookieKey: (key: string, prefix?: CookiePrefixOptions) => string | undefined;
190
+ /**
191
+ * Parse an HTTP Cookie header string and returning an object of all cookie
192
+ * name-value pairs.
193
+ *
194
+ * Inspired by https://github.com/unjs/cookie-es/blob/main/src/cookie/parse.ts
195
+ *
196
+ * @param str the string representing a `Cookie` header value
197
+ */
198
+ declare function parseCookies(str: string): Map<string, string>;
199
+ declare const serializeCookie: (key: string, value: string, opt?: CookieOptions) => string;
200
+ declare const serializeSignedCookie: (key: string, value: string, secret: string, opt?: CookieOptions) => Promise<string>;
201
+ //#endregion
202
+ //#region src/standard-schema.d.ts
203
+ /** The Standard Schema interface. */
204
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
205
+ /** The Standard Schema properties. */
206
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
207
+ }
208
+ declare namespace StandardSchemaV1 {
209
+ /** The Standard Schema properties interface. */
210
+ interface Props<Input = unknown, Output = Input> {
211
+ /** The version number of the standard. */
212
+ readonly version: 1;
213
+ /** The vendor name of the schema library. */
214
+ readonly vendor: string;
215
+ /** Validates unknown input values. */
216
+ readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
217
+ /** Inferred types associated with the schema. */
218
+ readonly types?: Types<Input, Output> | undefined;
219
+ }
220
+ /** The result interface of the validate function. */
221
+ type Result<Output> = SuccessResult<Output> | FailureResult;
222
+ /** The result interface if validation succeeds. */
223
+ interface SuccessResult<Output> {
224
+ /** The typed output value. */
225
+ readonly value: Output;
226
+ /** The non-existent issues. */
227
+ readonly issues?: undefined;
228
+ }
229
+ /** The result interface if validation fails. */
230
+ interface FailureResult {
231
+ /** The issues of failed validation. */
232
+ readonly issues: ReadonlyArray<Issue>;
233
+ }
234
+ /** The issue interface of the failure output. */
235
+ interface Issue {
236
+ /** The error message of the issue. */
237
+ readonly message: string;
238
+ /** The path of the issue, if any. */
239
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
240
+ }
241
+ /** The path segment interface of the issue. */
242
+ interface PathSegment {
243
+ /** The key representing a path segment. */
244
+ readonly key: PropertyKey;
245
+ }
246
+ /** The Standard Schema types interface. */
247
+ interface Types<Input = unknown, Output = Input> {
248
+ /** The input type of the schema. */
249
+ readonly input: Input;
250
+ /** The output type of the schema. */
251
+ readonly output: Output;
252
+ }
253
+ /** Infers the input type of a Standard Schema. */
254
+ type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
255
+ /** Infers the output type of a Standard Schema. */
256
+ type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
257
+ }
258
+ //#endregion
259
+ //#region src/context.d.ts
260
+ type HTTPMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
261
+ type Method = HTTPMethod | "*";
262
+ type InferBodyInput<Options extends EndpointOptions | MiddlewareOptions, Body = (Options["metadata"] extends {
263
+ $Infer: {
264
+ body: infer B;
265
+ };
266
+ } ? B : Options["body"] extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Options["body"]> : undefined)> = undefined extends Body ? {
267
+ body?: Body;
268
+ } : {
269
+ body: Body;
270
+ };
271
+ type InferBody<Options extends EndpointOptions | MiddlewareOptions> = Options["metadata"] extends {
272
+ $Infer: {
273
+ body: infer Body;
274
+ };
275
+ } ? Body : Options["body"] extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Options["body"]> : any;
276
+ type InferQueryInput<Options extends EndpointOptions | MiddlewareOptions, Query = (Options["metadata"] extends {
277
+ $Infer: {
278
+ query: infer Query;
279
+ };
280
+ } ? Query : Options["query"] extends StandardSchemaV1 ? StandardSchemaV1.InferInput<Options["query"]> : Record<string, any> | undefined)> = undefined extends Query ? {
281
+ query?: Query;
282
+ } : {
283
+ query: Query;
284
+ };
285
+ type InferQuery<Options extends EndpointOptions | MiddlewareOptions> = Options["metadata"] extends {
286
+ $Infer: {
287
+ query: infer Query;
288
+ };
289
+ } ? Query : Options["query"] extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<Options["query"]> : Record<string, any> | undefined;
290
+ type InferMethod<Options extends EndpointOptions> = Options["method"] extends Array<Method> ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"];
291
+ type InferInputMethod<Options extends EndpointOptions, Method = (Options["method"] extends Array<any> ? Options["method"][number] : Options["method"] extends "*" ? HTTPMethod : Options["method"] | undefined)> = undefined extends Method ? {
292
+ method?: Method;
293
+ } : {
294
+ method: Method;
295
+ };
296
+ type InferParam<Path extends string> = IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? Record<string, any> | undefined : Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
297
+ type InferParamInput<Path extends string> = IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? {
298
+ params?: Record<string, any>;
299
+ } : {
300
+ params: Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
301
+ };
302
+ type InferRequest<Option extends EndpointOptions | MiddlewareOptions> = Option["requireRequest"] extends true ? Request : Request | undefined;
303
+ type InferRequestInput<Option extends EndpointOptions | MiddlewareOptions> = Option["requireRequest"] extends true ? {
304
+ request: Request;
305
+ } : {
306
+ request?: Request;
307
+ };
308
+ type InferHeaders<Option extends EndpointOptions | MiddlewareOptions> = Option["requireHeaders"] extends true ? Headers : Headers | undefined;
309
+ type InferHeadersInput<Option extends EndpointOptions | MiddlewareOptions> = Option["requireHeaders"] extends true ? {
310
+ headers: HeadersInit;
311
+ } : {
312
+ headers?: HeadersInit;
313
+ };
314
+ type InferUse<Opts extends EndpointOptions["use"]> = Opts extends Middleware[] ? UnionToIntersection<Awaited<ReturnType<Opts[number]>>> : {};
315
+ type InferMiddlewareBody<Options extends MiddlewareOptions> = Options["body"] extends StandardSchemaV1<infer T> ? T : any;
316
+ type InferMiddlewareQuery<Options extends MiddlewareOptions> = Options["query"] extends StandardSchemaV1<infer T> ? T : Record<string, any> | undefined;
317
+ type InputContext<Path extends string, Options extends EndpointOptions> = InferBodyInput<Options> & InferInputMethod<Options> & InferQueryInput<Options> & InferParamInput<Path> & InferRequestInput<Options> & InferHeadersInput<Options> & {
318
+ asResponse?: boolean;
319
+ returnHeaders?: boolean;
320
+ use?: Middleware[];
321
+ path?: string;
322
+ };
323
+ declare const createInternalContext: (context: InputContext<any, any>, {
324
+ options,
325
+ path
326
+ }: {
327
+ options: EndpointOptions;
328
+ path: string;
329
+ }) => Promise<{
330
+ body: any;
331
+ query: any;
332
+ path: string;
333
+ context: {};
334
+ returned: any;
335
+ headers: HeadersInit | undefined;
336
+ request: Request | undefined;
337
+ params: Record<string, any> | undefined;
338
+ method: any;
339
+ setHeader: (key: string, value: string) => void;
340
+ getHeader: (key: string) => string | null;
341
+ getCookie: (key: string, prefix?: CookiePrefixOptions) => string | null;
342
+ getSignedCookie: (key: string, secret: string, prefix?: CookiePrefixOptions) => Promise<string | false | null>;
343
+ setCookie: (key: string, value: string, options?: CookieOptions) => string;
344
+ setSignedCookie: (key: string, value: string, secret: string, options?: CookieOptions) => Promise<string>;
345
+ redirect: (url: string) => {
346
+ status: keyof typeof _statusCode | Status;
347
+ body: ({
348
+ message?: string;
349
+ code?: string;
350
+ cause?: unknown;
351
+ } & Record<string, any>) | undefined;
352
+ headers: HeadersInit;
353
+ statusCode: number;
354
+ name: string;
355
+ message: string;
356
+ stack?: string;
357
+ cause?: unknown;
358
+ } & {
359
+ errorStack: string | undefined;
360
+ };
361
+ error: (status: keyof typeof _statusCode | Status, body?: {
362
+ message?: string;
363
+ code?: string;
364
+ } | undefined, headers?: HeadersInit) => {
365
+ status: keyof typeof _statusCode | Status;
366
+ body: ({
367
+ message?: string;
368
+ code?: string;
369
+ cause?: unknown;
370
+ } & Record<string, any>) | undefined;
371
+ headers: HeadersInit;
372
+ statusCode: number;
373
+ name: string;
374
+ message: string;
375
+ stack?: string;
376
+ cause?: unknown;
377
+ } & {
378
+ errorStack: string | undefined;
379
+ };
380
+ json: (json: Record<string, any>, routerResponse?: {
381
+ status?: number;
382
+ headers?: Record<string, string>;
383
+ response?: Response;
384
+ body?: Record<string, any>;
385
+ } | Response) => Record<string, any>;
386
+ responseHeaders: Headers;
387
+ asResponse?: boolean;
388
+ returnHeaders?: boolean;
389
+ use?: Middleware[];
390
+ } | {
391
+ body: any;
392
+ query: any;
393
+ path: string;
394
+ context: {};
395
+ returned: any;
396
+ headers: HeadersInit | undefined;
397
+ request: Request | undefined;
398
+ params: Record<string, any> | undefined;
399
+ method: any;
400
+ setHeader: (key: string, value: string) => void;
401
+ getHeader: (key: string) => string | null;
402
+ getCookie: (key: string, prefix?: CookiePrefixOptions) => string | null;
403
+ getSignedCookie: (key: string, secret: string, prefix?: CookiePrefixOptions) => Promise<string | false | null>;
404
+ setCookie: (key: string, value: string, options?: CookieOptions) => string;
405
+ setSignedCookie: (key: string, value: string, secret: string, options?: CookieOptions) => Promise<string>;
406
+ redirect: (url: string) => {
407
+ status: keyof typeof _statusCode | Status;
408
+ body: ({
409
+ message?: string;
410
+ code?: string;
411
+ cause?: unknown;
412
+ } & Record<string, any>) | undefined;
413
+ headers: HeadersInit;
414
+ statusCode: number;
415
+ name: string;
416
+ message: string;
417
+ stack?: string;
418
+ cause?: unknown;
419
+ } & {
420
+ errorStack: string | undefined;
421
+ };
422
+ error: (status: keyof typeof _statusCode | Status, body?: {
423
+ message?: string;
424
+ code?: string;
425
+ } | undefined, headers?: HeadersInit) => {
426
+ status: keyof typeof _statusCode | Status;
427
+ body: ({
428
+ message?: string;
429
+ code?: string;
430
+ cause?: unknown;
431
+ } & Record<string, any>) | undefined;
432
+ headers: HeadersInit;
433
+ statusCode: number;
434
+ name: string;
435
+ message: string;
436
+ stack?: string;
437
+ cause?: unknown;
438
+ } & {
439
+ errorStack: string | undefined;
440
+ };
441
+ json: (json: Record<string, any>, routerResponse?: {
442
+ status?: number;
443
+ headers?: Record<string, string>;
444
+ response?: Response;
445
+ body?: Record<string, any>;
446
+ } | Response) => Record<string, any>;
447
+ responseHeaders: Headers;
448
+ asResponse?: boolean;
449
+ returnHeaders?: boolean;
450
+ use?: Middleware[];
451
+ } | {
452
+ body: any;
453
+ query: any;
454
+ path: string;
455
+ context: {};
456
+ returned: any;
457
+ headers: HeadersInit | undefined;
458
+ request: Request | undefined;
459
+ params: Record<string, any> | undefined;
460
+ method: any;
461
+ setHeader: (key: string, value: string) => void;
462
+ getHeader: (key: string) => string | null;
463
+ getCookie: (key: string, prefix?: CookiePrefixOptions) => string | null;
464
+ getSignedCookie: (key: string, secret: string, prefix?: CookiePrefixOptions) => Promise<string | false | null>;
465
+ setCookie: (key: string, value: string, options?: CookieOptions) => string;
466
+ setSignedCookie: (key: string, value: string, secret: string, options?: CookieOptions) => Promise<string>;
467
+ redirect: (url: string) => {
468
+ status: keyof typeof _statusCode | Status;
469
+ body: ({
470
+ message?: string;
471
+ code?: string;
472
+ cause?: unknown;
473
+ } & Record<string, any>) | undefined;
474
+ headers: HeadersInit;
475
+ statusCode: number;
476
+ name: string;
477
+ message: string;
478
+ stack?: string;
479
+ cause?: unknown;
480
+ } & {
481
+ errorStack: string | undefined;
482
+ };
483
+ error: (status: keyof typeof _statusCode | Status, body?: {
484
+ message?: string;
485
+ code?: string;
486
+ } | undefined, headers?: HeadersInit) => {
487
+ status: keyof typeof _statusCode | Status;
488
+ body: ({
489
+ message?: string;
490
+ code?: string;
491
+ cause?: unknown;
492
+ } & Record<string, any>) | undefined;
493
+ headers: HeadersInit;
494
+ statusCode: number;
495
+ name: string;
496
+ message: string;
497
+ stack?: string;
498
+ cause?: unknown;
499
+ } & {
500
+ errorStack: string | undefined;
501
+ };
502
+ json: (json: Record<string, any>, routerResponse?: {
503
+ status?: number;
504
+ headers?: Record<string, string>;
505
+ response?: Response;
506
+ body?: Record<string, any>;
507
+ } | Response) => Record<string, any>;
508
+ responseHeaders: Headers;
509
+ asResponse?: boolean;
510
+ returnHeaders?: boolean;
511
+ use?: Middleware[];
512
+ } | {
513
+ body: any;
514
+ query: any;
515
+ path: string;
516
+ context: {};
517
+ returned: any;
518
+ headers: HeadersInit | undefined;
519
+ request: Request | undefined;
520
+ params: Record<string, any> | undefined;
521
+ method: any;
522
+ setHeader: (key: string, value: string) => void;
523
+ getHeader: (key: string) => string | null;
524
+ getCookie: (key: string, prefix?: CookiePrefixOptions) => string | null;
525
+ getSignedCookie: (key: string, secret: string, prefix?: CookiePrefixOptions) => Promise<string | false | null>;
526
+ setCookie: (key: string, value: string, options?: CookieOptions) => string;
527
+ setSignedCookie: (key: string, value: string, secret: string, options?: CookieOptions) => Promise<string>;
528
+ redirect: (url: string) => {
529
+ status: keyof typeof _statusCode | Status;
530
+ body: ({
531
+ message?: string;
532
+ code?: string;
533
+ cause?: unknown;
534
+ } & Record<string, any>) | undefined;
535
+ headers: HeadersInit;
536
+ statusCode: number;
537
+ name: string;
538
+ message: string;
539
+ stack?: string;
540
+ cause?: unknown;
541
+ } & {
542
+ errorStack: string | undefined;
543
+ };
544
+ error: (status: keyof typeof _statusCode | Status, body?: {
545
+ message?: string;
546
+ code?: string;
547
+ } | undefined, headers?: HeadersInit) => {
548
+ status: keyof typeof _statusCode | Status;
549
+ body: ({
550
+ message?: string;
551
+ code?: string;
552
+ cause?: unknown;
553
+ } & Record<string, any>) | undefined;
554
+ headers: HeadersInit;
555
+ statusCode: number;
556
+ name: string;
557
+ message: string;
558
+ stack?: string;
559
+ cause?: unknown;
560
+ } & {
561
+ errorStack: string | undefined;
562
+ };
563
+ json: (json: Record<string, any>, routerResponse?: {
564
+ status?: number;
565
+ headers?: Record<string, string>;
566
+ response?: Response;
567
+ body?: Record<string, any>;
568
+ } | Response) => Record<string, any>;
569
+ responseHeaders: Headers;
570
+ asResponse?: boolean;
571
+ returnHeaders?: boolean;
572
+ use?: Middleware[];
573
+ }>;
574
+ //#endregion
575
+ //#region src/middleware.d.ts
576
+ interface MiddlewareOptions extends Omit<EndpointOptions, "method"> {}
577
+ type MiddlewareResponse = null | void | undefined | Record<string, any>;
578
+ type MiddlewareContext<Options extends MiddlewareOptions, Context = {}> = EndpointContext<string, Options & {
579
+ method: "*";
580
+ }> & {
581
+ /**
582
+ * Method
583
+ *
584
+ * The request method
585
+ */
586
+ method: string;
587
+ /**
588
+ * Path
589
+ *
590
+ * The path of the endpoint
591
+ */
592
+ path: string;
593
+ /**
594
+ * Body
595
+ *
596
+ * The body object will be the parsed JSON from the request and validated
597
+ * against the body schema if it exists
598
+ */
599
+ body: InferMiddlewareBody<Options>;
600
+ /**
601
+ * Query
602
+ *
603
+ * The query object will be the parsed query string from the request
604
+ * and validated against the query schema if it exists
605
+ */
606
+ query: InferMiddlewareQuery<Options>;
607
+ /**
608
+ * Params
609
+ *
610
+ * If the path is `/user/:id` and the request is `/user/1` then the
611
+ * params will
612
+ * be `{ id: "1" }` and if the path includes a wildcard like `/user/*`
613
+ * then the
614
+ * params will be `{ _: "1" }` where `_` is the wildcard key. If the
615
+ * wildcard
616
+ * is named like `/user/**:name` then the params will be `{ name: string }`
617
+ */
618
+ params: string;
619
+ /**
620
+ * Request object
621
+ *
622
+ * If `requireRequest` is set to true in the endpoint options this will be
623
+ * required
624
+ */
625
+ request: InferRequest<Options>;
626
+ /**
627
+ * Headers
628
+ *
629
+ * If `requireHeaders` is set to true in the endpoint options this will be
630
+ * required
631
+ */
632
+ headers: InferHeaders<Options>;
633
+ /**
634
+ * Set header
635
+ *
636
+ * If it's called outside of a request it will just be ignored.
637
+ */
638
+ setHeader: (key: string, value: string) => void;
639
+ /**
640
+ * Get header
641
+ *
642
+ * If it's called outside of a request it will just return null
643
+ *
644
+ * @param key - The key of the header
645
+ * @returns
646
+ */
647
+ getHeader: (key: string) => string | null;
648
+ /**
649
+ * JSON
650
+ *
651
+ * a helper function to create a JSON response with
652
+ * the correct headers
653
+ * and status code. If `asResponse` is set to true in
654
+ * the context then
655
+ * it will return a Response object instead of the
656
+ * JSON object.
657
+ *
658
+ * @param json - The JSON object to return
659
+ * @param routerResponse - The response object to
660
+ * return if `asResponse` is
661
+ * true in the context this will take precedence
662
+ */
663
+ json: <R extends Record<string, any> | null>(json: R, routerResponse?: {
664
+ status?: number;
665
+ headers?: Record<string, string>;
666
+ response?: Response;
667
+ } | Response) => Promise<R>;
668
+ /**
669
+ * Middleware context
670
+ */
671
+ context: Prettify<Context>;
672
+ };
673
+ declare function createMiddleware<Options extends MiddlewareOptions, R>(options: Options, handler: (context: MiddlewareContext<Options>) => Promise<R>): <InputCtx extends MiddlewareInputContext<Options>>(inputContext: InputCtx) => Promise<R>;
674
+ declare function createMiddleware<Options extends MiddlewareOptions, R>(handler: (context: MiddlewareContext<Options>) => Promise<R>): <InputCtx extends MiddlewareInputContext<Options>>(inputContext: InputCtx) => Promise<R>;
675
+ declare namespace createMiddleware {
676
+ var create: <E extends {
677
+ use?: Middleware[];
678
+ }>(opts?: E) => {
679
+ <Options extends MiddlewareOptions, R>(options: Options, handler: (ctx: MiddlewareContext<Options, InferUse<E["use"]>>) => Promise<R>): (inputContext: MiddlewareInputContext<Options>) => Promise<R>;
680
+ <Options extends MiddlewareOptions, R_1>(handler: (ctx: MiddlewareContext<Options, InferUse<E["use"]>>) => Promise<R_1>): (inputContext: MiddlewareInputContext<Options>) => Promise<R_1>;
681
+ };
682
+ }
683
+ type MiddlewareInputContext<Options extends MiddlewareOptions> = InferBodyInput<Options> & InferQueryInput<Options> & InferRequestInput<Options> & InferHeadersInput<Options> & {
684
+ asResponse?: boolean;
685
+ returnHeaders?: boolean;
686
+ use?: Middleware[];
687
+ };
688
+ type Middleware<Options extends MiddlewareOptions = MiddlewareOptions, Handler extends (inputCtx: any) => Promise<any> = any> = Handler & {
689
+ options: Options;
690
+ };
691
+ //#endregion
692
+ //#region src/openapi.d.ts
693
+ type OpenAPISchemaType = "string" | "number" | "integer" | "boolean" | "array" | "object";
694
+ interface OpenAPIParameter {
695
+ in: "query" | "path" | "header" | "cookie";
696
+ name?: string;
697
+ description?: string;
698
+ required?: boolean;
699
+ schema?: {
700
+ type: OpenAPISchemaType;
701
+ format?: string;
702
+ items?: {
703
+ type: OpenAPISchemaType;
704
+ };
705
+ enum?: string[];
706
+ minLength?: number;
707
+ description?: string;
708
+ default?: string;
709
+ example?: string;
710
+ };
711
+ }
712
+ interface Path$1 {
713
+ get?: {
714
+ tags?: string[];
715
+ operationId?: string;
716
+ description?: string;
717
+ security?: [{
718
+ bearerAuth: string[];
719
+ }];
720
+ parameters?: OpenAPIParameter[];
721
+ responses?: { [key in string]: {
722
+ description?: string;
723
+ content: {
724
+ "application/json": {
725
+ schema: {
726
+ type?: OpenAPISchemaType;
727
+ properties?: Record<string, any>;
728
+ required?: string[];
729
+ $ref?: string;
730
+ };
731
+ };
732
+ };
733
+ } };
734
+ };
735
+ post?: {
736
+ tags?: string[];
737
+ operationId?: string;
738
+ description?: string;
739
+ security?: [{
740
+ bearerAuth: string[];
741
+ }];
742
+ parameters?: OpenAPIParameter[];
743
+ requestBody?: {
744
+ content: {
745
+ "application/json": {
746
+ schema: {
747
+ type?: OpenAPISchemaType;
748
+ properties?: Record<string, any>;
749
+ required?: string[];
750
+ $ref?: string;
751
+ };
752
+ };
753
+ };
754
+ };
755
+ responses?: { [key in string]: {
756
+ description?: string;
757
+ content: {
758
+ "application/json": {
759
+ schema: {
760
+ type?: OpenAPISchemaType;
761
+ properties?: Record<string, any>;
762
+ required?: string[];
763
+ $ref?: string;
764
+ };
765
+ };
766
+ };
767
+ } };
768
+ };
769
+ }
770
+ declare function generator(endpoints: Record<string, Endpoint>, config?: {
771
+ url: string;
772
+ }): Promise<{
773
+ openapi: string;
774
+ info: {
775
+ title: string;
776
+ description: string;
777
+ version: string;
778
+ };
779
+ components: {
780
+ schemas: {};
781
+ };
782
+ security: {
783
+ apiKeyCookie: never[];
784
+ }[];
785
+ servers: {
786
+ url: string | undefined;
787
+ }[];
788
+ tags: {
789
+ name: string;
790
+ description: string;
791
+ }[];
792
+ paths: Record<string, Path$1>;
793
+ }>;
794
+ declare const getHTML: (apiReference: Record<string, any>, config?: {
795
+ logo?: string;
796
+ theme?: string;
797
+ title?: string;
798
+ description?: string;
799
+ }) => string;
800
+ //#endregion
801
+ //#region src/endpoint.d.ts
802
+ interface EndpointOptions {
803
+ /**
804
+ * Request Method
805
+ */
806
+ method: Method | Method[];
807
+ /**
808
+ * Body Schema
809
+ */
810
+ body?: StandardSchemaV1;
811
+ /**
812
+ * Query Schema
813
+ */
814
+ query?: StandardSchemaV1;
815
+ /**
816
+ * Error Schema
817
+ */
818
+ error?: StandardSchemaV1;
819
+ /**
820
+ * If true headers will be required to be passed in the context
821
+ */
822
+ requireHeaders?: boolean;
823
+ /**
824
+ * If true request object will be required
825
+ */
826
+ requireRequest?: boolean;
827
+ /**
828
+ * Clone the request object from the router
829
+ */
830
+ cloneRequest?: boolean;
831
+ /**
832
+ * If true the body will be undefined
833
+ */
834
+ disableBody?: boolean;
835
+ /**
836
+ * Endpoint metadata
837
+ */
838
+ metadata?: {
839
+ /**
840
+ * Open API definition
841
+ */
842
+ openapi?: {
843
+ summary?: string;
844
+ description?: string;
845
+ tags?: string[];
846
+ operationId?: string;
847
+ parameters?: OpenAPIParameter[];
848
+ requestBody?: {
849
+ content: {
850
+ "application/json": {
851
+ schema: {
852
+ type?: OpenAPISchemaType;
853
+ properties?: Record<string, any>;
854
+ required?: string[];
855
+ $ref?: string;
856
+ };
857
+ };
858
+ };
859
+ };
860
+ responses?: {
861
+ [status: string]: {
862
+ description: string;
863
+ content?: {
864
+ "application/json"?: {
865
+ schema: {
866
+ type?: OpenAPISchemaType;
867
+ properties?: Record<string, any>;
868
+ required?: string[];
869
+ $ref?: string;
870
+ };
871
+ };
872
+ "text/plain"?: {
873
+ schema?: {
874
+ type?: OpenAPISchemaType;
875
+ properties?: Record<string, any>;
876
+ required?: string[];
877
+ $ref?: string;
878
+ };
879
+ };
880
+ "text/html"?: {
881
+ schema?: {
882
+ type?: OpenAPISchemaType;
883
+ properties?: Record<string, any>;
884
+ required?: string[];
885
+ $ref?: string;
886
+ };
887
+ };
888
+ };
889
+ };
890
+ };
891
+ };
892
+ /**
893
+ * Infer body and query type from ts interface
894
+ *
895
+ * useful for generic and dynamic types
896
+ *
897
+ * @example
898
+ * ```ts
899
+ * const endpoint = createEndpoint("/path", {
900
+ * method: "POST",
901
+ * body: z.record(z.string()),
902
+ * $Infer: {
903
+ * body: {} as {
904
+ * type: InferTypeFromOptions<Option> // custom type inference
905
+ * }
906
+ * }
907
+ * }, async(ctx)=>{
908
+ * const body = ctx.body
909
+ * })
910
+ * ```
911
+ */
912
+ $Infer?: {
913
+ /**
914
+ * Body
915
+ */
916
+ body?: any;
917
+ /**
918
+ * Query
919
+ */
920
+ query?: Record<string, any>;
921
+ };
922
+ /**
923
+ * If enabled, endpoint won't be exposed over a router
924
+ */
925
+ SERVER_ONLY?: boolean;
926
+ /**
927
+ * Extra metadata
928
+ */
929
+ [key: string]: any;
930
+ };
931
+ /**
932
+ * List of middlewares to use
933
+ */
934
+ use?: Middleware[];
935
+ /**
936
+ * A callback to run before any API error is throw or returned
937
+ *
938
+ * @param e - The API error
939
+ * @returns - The response to return
940
+ */
941
+ onAPIError?: (e: APIError) => void | Promise<void>;
942
+ }
943
+ type EndpointContext<Path extends string, Options extends EndpointOptions, Context = {}> = {
944
+ /**
945
+ * Method
946
+ *
947
+ * The request method
948
+ */
949
+ method: InferMethod<Options>;
950
+ /**
951
+ * Path
952
+ *
953
+ * The path of the endpoint
954
+ */
955
+ path: Path;
956
+ /**
957
+ * Body
958
+ *
959
+ * The body object will be the parsed JSON from the request and validated
960
+ * against the body schema if it exists.
961
+ */
962
+ body: InferBody<Options>;
963
+ /**
964
+ * Query
965
+ *
966
+ * The query object will be the parsed query string from the request
967
+ * and validated against the query schema if it exists
968
+ */
969
+ query: InferQuery<Options>;
970
+ /**
971
+ * Params
972
+ *
973
+ * If the path is `/user/:id` and the request is `/user/1` then the params will
974
+ * be `{ id: "1" }` and if the path includes a wildcard like `/user/*` then the
975
+ * params will be `{ _: "1" }` where `_` is the wildcard key. If the wildcard
976
+ * is named like `/user/**:name` then the params will be `{ name: string }`
977
+ */
978
+ params: InferParam<Path>;
979
+ /**
980
+ * Request object
981
+ *
982
+ * If `requireRequest` is set to true in the endpoint options this will be
983
+ * required
984
+ */
985
+ request: InferRequest<Options>;
986
+ /**
987
+ * Headers
988
+ *
989
+ * If `requireHeaders` is set to true in the endpoint options this will be
990
+ * required
991
+ */
992
+ headers: InferHeaders<Options>;
993
+ /**
994
+ * Set header
995
+ *
996
+ * If it's called outside of a request it will just be ignored.
997
+ */
998
+ setHeader: (key: string, value: string) => void;
999
+ /**
1000
+ * Get header
1001
+ *
1002
+ * If it's called outside of a request it will just return null
1003
+ *
1004
+ * @param key - The key of the header
1005
+ * @returns
1006
+ */
1007
+ getHeader: (key: string) => string | null;
1008
+ /**
1009
+ * Get a cookie value from the request
1010
+ *
1011
+ * @param key - The key of the cookie
1012
+ * @param prefix - The prefix of the cookie between `__Secure-` and `__Host-`
1013
+ * @returns - The value of the cookie
1014
+ */
1015
+ getCookie: (key: string, prefix?: CookiePrefixOptions) => string | null;
1016
+ /**
1017
+ * Get a signed cookie value from the request
1018
+ *
1019
+ * @param key - The key of the cookie
1020
+ * @param secret - The secret of the signed cookie
1021
+ * @param prefix - The prefix of the cookie between `__Secure-` and `__Host-`
1022
+ * @returns
1023
+ */
1024
+ getSignedCookie: (key: string, secret: string, prefix?: CookiePrefixOptions) => Promise<string | null>;
1025
+ /**
1026
+ * Set a cookie value in the response
1027
+ *
1028
+ * @param key - The key of the cookie
1029
+ * @param value - The value to set
1030
+ * @param options - The options of the cookie
1031
+ * @returns - The cookie string
1032
+ */
1033
+ setCookie: (key: string, value: string, options?: CookieOptions) => string;
1034
+ /**
1035
+ * Set signed cookie
1036
+ *
1037
+ * @param key - The key of the cookie
1038
+ * @param value - The value to set
1039
+ * @param secret - The secret to sign the cookie with
1040
+ * @param options - The options of the cookie
1041
+ * @returns - The cookie string
1042
+ */
1043
+ setSignedCookie: (key: string, value: string, secret: string, options?: CookieOptions) => Promise<string>;
1044
+ /**
1045
+ * JSON
1046
+ *
1047
+ * a helper function to create a JSON response with
1048
+ * the correct headers
1049
+ * and status code. If `asResponse` is set to true in
1050
+ * the context then
1051
+ * it will return a Response object instead of the
1052
+ * JSON object.
1053
+ *
1054
+ * @param json - The JSON object to return
1055
+ * @param routerResponse - The response object to
1056
+ * return if `asResponse` is
1057
+ * true in the context this will take precedence
1058
+ */
1059
+ json: <R extends Record<string, any> | null>(json: R, routerResponse?: {
1060
+ status?: number;
1061
+ headers?: Record<string, string>;
1062
+ response?: Response;
1063
+ body?: Record<string, string>;
1064
+ } | Response) => Promise<R>;
1065
+ /**
1066
+ * Middleware context
1067
+ */
1068
+ context: Prettify<Context & InferUse<Options["use"]>>;
1069
+ /**
1070
+ * Redirect to a new URL
1071
+ */
1072
+ redirect: (url: string) => APIError;
1073
+ /**
1074
+ * Return error
1075
+ */
1076
+ error: (status: keyof typeof _statusCode | Status, body?: {
1077
+ message?: string;
1078
+ code?: string;
1079
+ } & Record<string, any>, headers?: HeadersInit) => APIError;
1080
+ };
1081
+ declare const createEndpoint: {
1082
+ <Path extends string, Options extends EndpointOptions, R>(path: Path, options: Options, handler: (context: EndpointContext<Path, Options>) => Promise<R>): StrictEndpoint<Path, Options, R>;
1083
+ create<E extends {
1084
+ use?: Middleware[];
1085
+ }>(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) => StrictEndpoint<Path, Opts & {
1086
+ use: any[];
1087
+ }, any>;
1088
+ };
1089
+ type StrictEndpoint<Path extends string, Options extends EndpointOptions, R = any> = {
1090
+ (context: InputContext<Path, Options> & {
1091
+ asResponse: true;
1092
+ }): Promise<Response>;
1093
+ (context: InputContext<Path, Options> & {
1094
+ asResponse: false;
1095
+ returnHeaders?: false;
1096
+ }): Promise<R>;
1097
+ (context: InputContext<Path, Options> & {
1098
+ asResponse?: false;
1099
+ returnHeaders: true;
1100
+ }): Promise<{
1101
+ headers: Headers;
1102
+ response: Awaited<R>;
1103
+ }>;
1104
+ (context?: InputContext<Path, Options>): Promise<R>;
1105
+ wrap: <T>(fn: (context: EndpointContext<Path, Options>, original: (context: EndpointContext<Path, Options>) => Promise<any>) => T) => StrictEndpoint<Path, Options, Promise<T>>;
1106
+ options: Options;
1107
+ path: Path;
1108
+ };
1109
+ type Endpoint<Path extends string = string, Options extends EndpointOptions = EndpointOptions, Handler extends (inputCtx: any) => Promise<any> = (inputCtx: any) => Promise<any>> = Handler & {
1110
+ options: Options;
1111
+ path: Path;
1112
+ };
1113
+ //#endregion
1114
+ //#region src/router.d.ts
1115
+ interface RouterConfig {
1116
+ throwError?: boolean;
1117
+ onError?: (e: unknown) => void | Promise<void> | Response | Promise<Response>;
1118
+ basePath?: string;
1119
+ routerMiddleware?: Array<{
1120
+ path: string;
1121
+ middleware: Middleware;
1122
+ }>;
1123
+ /**
1124
+ * additional Context that needs to passed to endpoints
1125
+ *
1126
+ * this will be available on `ctx.context` on endpoints
1127
+ */
1128
+ routerContext?: Record<string, any>;
1129
+ /**
1130
+ * A callback to run before any response
1131
+ */
1132
+ onResponse?: (res: Response) => any | Promise<any>;
1133
+ /**
1134
+ * A callback to run before any request
1135
+ */
1136
+ onRequest?: (req: Request) => any | Promise<any>;
1137
+ /**
1138
+ * Open API route configuration
1139
+ */
1140
+ openapi?: {
1141
+ /**
1142
+ * Disable openapi route
1143
+ *
1144
+ * @default false
1145
+ */
1146
+ disabled?: boolean;
1147
+ /**
1148
+ * A path to display open api using scalar
1149
+ *
1150
+ * @default "/api/reference"
1151
+ */
1152
+ path?: string;
1153
+ /**
1154
+ * Scalar Configuration
1155
+ */
1156
+ scalar?: {
1157
+ /**
1158
+ * Title
1159
+ * @default "Open API Reference"
1160
+ */
1161
+ title?: string;
1162
+ /**
1163
+ * Description
1164
+ *
1165
+ * @default "Better Call Open API Reference"
1166
+ */
1167
+ description?: string;
1168
+ /**
1169
+ * Logo URL
1170
+ */
1171
+ logo?: string;
1172
+ /**
1173
+ * Scalar theme
1174
+ * @default "saturn"
1175
+ */
1176
+ theme?: string;
1177
+ };
1178
+ };
1179
+ }
1180
+ declare const createRouter: <E extends Record<string, Endpoint>, Config extends RouterConfig>(endpoints: E, config?: Config) => {
1181
+ handler: (request: Request) => Promise<Response>;
1182
+ endpoints: E;
1183
+ };
1184
+ type Router = ReturnType<typeof createRouter>;
1185
+ //#endregion
1186
+ export { APIError, CookieOptions, CookiePrefixOptions, Endpoint, EndpointContext, EndpointOptions, HTTPMethod, HasRequiredKeys, InferBody, InferBodyInput, InferHeaders, InferHeadersInput, InferInputMethod, InferMethod, InferMiddlewareBody, InferMiddlewareQuery, InferParam, InferParamInput, InferParamPath, InferParamWildCard, InferQuery, InferQueryInput, InferRequest, InferRequestInput, InferUse, InputContext, IsEmptyObject, MergeObject, Method, Middleware, MiddlewareContext, MiddlewareInputContext, MiddlewareOptions, MiddlewareResponse, OpenAPIParameter, OpenAPISchemaType, Path$1 as Path, Prettify, RequiredKeysOf, Router, RouterConfig, StandardSchemaV1, Status, StrictEndpoint, UnionToIntersection, _statusCode, createEndpoint, createInternalContext, createMiddleware, createRouter, generator, getCookieKey, getHTML, hideInternalStackFrames, makeErrorForHideStackFrame, parseCookies, serializeCookie, serializeSignedCookie };
1187
+ //# sourceMappingURL=router-B4CojZF8.d.cts.map