routup 5.2.0 → 6.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1159 +0,0 @@
1
- import { FastURL, ServerRequest } from "srvx";
2
- import { HTTPError, HTTPErrorInput, HTTPErrorInput as HTTPErrorInput$1 } from "@ebec/http";
3
- import Negotiator from "negotiator";
4
- import { Key, ParseOptions, PathToRegexpOptions } from "path-to-regexp";
5
- import { IncomingMessage, ServerResponse } from "node:http";
6
-
7
- //#region src/constants.d.ts
8
- declare const MethodName: {
9
- readonly GET: "GET";
10
- readonly POST: "POST";
11
- readonly PUT: "PUT";
12
- readonly PATCH: "PATCH";
13
- readonly DELETE: "DELETE";
14
- readonly OPTIONS: "OPTIONS";
15
- readonly HEAD: "HEAD";
16
- };
17
- type MethodName = typeof MethodName[keyof typeof MethodName];
18
- declare const HeaderName: {
19
- readonly ACCEPT: "accept";
20
- readonly ACCEPT_CHARSET: "accept-charset";
21
- readonly ACCEPT_ENCODING: "accept-encoding";
22
- readonly ACCEPT_LANGUAGE: "accept-language";
23
- readonly ACCEPT_RANGES: "accept-ranges";
24
- readonly ALLOW: "allow";
25
- readonly CACHE_CONTROL: "cache-control";
26
- readonly CONTENT_DISPOSITION: "content-disposition";
27
- readonly CONTENT_ENCODING: "content-encoding";
28
- readonly CONTENT_LENGTH: "content-length";
29
- readonly CONTENT_RANGE: "content-range";
30
- readonly CONTENT_TYPE: "content-type";
31
- readonly CONNECTION: "connection";
32
- readonly COOKIE: "cookie";
33
- readonly ETag: "etag";
34
- readonly HOST: "host";
35
- readonly IF_MODIFIED_SINCE: "if-modified-since";
36
- readonly IF_NONE_MATCH: "if-none-match";
37
- readonly LAST_MODIFIED: "last-modified";
38
- readonly LOCATION: "location";
39
- readonly RANGE: "range";
40
- readonly RATE_LIMIT_LIMIT: "ratelimit-limit";
41
- readonly RATE_LIMIT_REMAINING: "ratelimit-remaining";
42
- readonly RATE_LIMIT_RESET: "ratelimit-reset";
43
- readonly RETRY_AFTER: "retry-after";
44
- readonly SET_COOKIE: "set-cookie";
45
- readonly TRANSFER_ENCODING: "transfer-encoding";
46
- readonly X_ACCEL_BUFFERING: "x-accel-buffering";
47
- readonly X_FORWARDED_HOST: "x-forwarded-host";
48
- readonly X_FORWARDED_FOR: "x-forwarded-for";
49
- readonly X_FORWARDED_PROTO: "x-forwarded-proto";
50
- };
51
- type HeaderName = typeof HeaderName[keyof typeof HeaderName];
52
- //#endregion
53
- //#region src/error/module.d.ts
54
- declare const ErrorSymbol: unique symbol;
55
- declare class RoutupError extends HTTPError {
56
- constructor(input?: HTTPErrorInput$1);
57
- }
58
- //#endregion
59
- //#region src/event/types.d.ts
60
- type RoutupResponse = {
61
- status: number;
62
- headers: Headers;
63
- };
64
- type RoutupRequest = ServerRequest;
65
- type NextFn = (error?: Error) => unknown | Promise<unknown>;
66
- interface IRoutupEvent {
67
- /**
68
- * The srvx ServerRequest (extends Web Standard Request).
69
- */
70
- readonly request: RoutupRequest;
71
- /**
72
- * Route parameters extracted from the URL path pattern.
73
- */
74
- readonly params: Record<string, any>;
75
- /**
76
- * Current request path, adjusted relative to the mount point during router nesting.
77
- */
78
- readonly path: string;
79
- /**
80
- * HTTP method (GET, POST, PUT, etc.).
81
- */
82
- readonly method: string;
83
- /**
84
- * Accumulated mount path from nested routers.
85
- */
86
- readonly mountPath: string;
87
- /**
88
- * Web Standard Headers from the request.
89
- */
90
- readonly headers: Headers;
91
- /**
92
- * Lazily-parsed URL search parameters.
93
- *
94
- * For advanced query parsing (arrays, nesting), use `@routup/query`.
95
- */
96
- readonly searchParams: URLSearchParams;
97
- /**
98
- * Response accumulator — set status/headers before returning a plain value.
99
- *
100
- * If the handler returns a `Response` object directly, these values are
101
- * ignored. They only apply when returning plain values (string, object, etc.)
102
- * that go through `toResponse()`.
103
- */
104
- readonly response: RoutupResponse;
105
- /**
106
- * Per-request store for caching and plugin state.
107
- *
108
- * Use symbol keys (e.g., `Symbol.for('routup:body')`) to avoid collisions.
109
- * Data is garbage collected with the event when the request completes.
110
- */
111
- readonly store: Record<string | symbol, unknown>;
112
- /**
113
- * Pre-resolved router options for the current dispatch context.
114
- *
115
- * Contains merged options from the router path stack with defaults applied.
116
- */
117
- readonly routerOptions: RouterOptions;
118
- /**
119
- * Abort signal tied to the request lifecycle.
120
- *
121
- * When a `timeout` router option is set, this signal aborts after the
122
- * specified duration. Handlers performing long I/O (fetch, streams, DB queries)
123
- * can pass this signal to those operations for cooperative cancellation.
124
- */
125
- readonly signal: AbortSignal;
126
- /**
127
- * Call the next handler in the pipeline (onion model).
128
- *
129
- * The result is cached — calling `next()` multiple times returns the same response.
130
- * Returns the downstream `Response`, or `undefined` if no handler matched.
131
- */
132
- next(error?: Error): Promise<Response | undefined>;
133
- /**
134
- * Whether `next()` has been invoked on this event.
135
- *
136
- * Used by the dispatch pipeline to disambiguate an `undefined` return value:
137
- * a handler that returns `undefined` after calling `next()` is forwarding the
138
- * downstream result; one that returns `undefined` without calling `next()` is
139
- * unresolved and will wait on `signal` (timeout-bounded).
140
- */
141
- readonly nextCalled: boolean;
142
- /**
143
- * The cached promise returned by the first `next()` call on this event,
144
- * or `undefined` if `next()` has not been invoked.
145
- */
146
- readonly nextResult: Promise<Response | undefined> | undefined;
147
- /**
148
- * Returns a promise that resolves the first time `next()` is invoked on this event.
149
- *
150
- * If `next()` has already been called, the returned promise is already resolved.
151
- * Used by the dispatch pipeline so a handler that returns `undefined` and later
152
- * calls `next()` asynchronously (e.g. from a `setTimeout`) still propagates the
153
- * downstream response instead of hanging until `signal` aborts.
154
- */
155
- whenNextCalled(): Promise<void>;
156
- }
157
- //#endregion
158
- //#region src/event/module.d.ts
159
- type RoutupEventCreateContext = {
160
- request: RoutupRequest;
161
- params: Record<string, any>;
162
- path: string;
163
- method: string;
164
- mountPath: string;
165
- headers: Headers;
166
- searchParams: URLSearchParams;
167
- response: RoutupResponse;
168
- store: Record<string | symbol, unknown>;
169
- signal: AbortSignal;
170
- routerOptions: () => RouterOptions;
171
- next: (event: IRoutupEvent, error?: Error) => Promise<Response | undefined>;
172
- };
173
- declare class RoutupEvent implements IRoutupEvent {
174
- readonly request: RoutupRequest;
175
- readonly params: Record<string, any>;
176
- readonly path: string;
177
- readonly method: string;
178
- readonly mountPath: string;
179
- readonly headers: Headers;
180
- readonly searchParams: URLSearchParams;
181
- readonly response: RoutupResponse;
182
- readonly store: Record<string | symbol, unknown>;
183
- readonly signal: AbortSignal;
184
- protected _context: RoutupEventCreateContext;
185
- protected _routerOptions?: RouterOptions;
186
- protected _nextCalled: boolean;
187
- protected _nextResult: Promise<Response | undefined> | undefined;
188
- protected _nextCalledDeferred: {
189
- promise: Promise<void>;
190
- resolve: () => void;
191
- } | undefined;
192
- constructor(context: RoutupEventCreateContext);
193
- get routerOptions(): RouterOptions;
194
- get nextCalled(): boolean;
195
- get nextResult(): Promise<Response | undefined> | undefined;
196
- whenNextCalled(): Promise<void>;
197
- next(error?: Error): Promise<Response | undefined>;
198
- }
199
- //#endregion
200
- //#region src/hook/constants.d.ts
201
- declare const HookName: {
202
- readonly REQUEST: "request";
203
- readonly RESPONSE: "response";
204
- readonly ERROR: "error";
205
- readonly CHILD_MATCH: "childMatch";
206
- readonly CHILD_DISPATCH_BEFORE: "childDispatchBefore";
207
- readonly CHILD_DISPATCH_AFTER: "childDispatchAfter";
208
- };
209
- type HookName = typeof HookName[keyof typeof HookName];
210
- //#endregion
211
- //#region src/dispatcher/types.d.ts
212
- interface IDispatcherEvent {
213
- /**
214
- * The srvx ServerRequest (extends Web Standard Request).
215
- */
216
- readonly request: RoutupRequest;
217
- /**
218
- * Route parameters extracted from the URL path pattern.
219
- */
220
- params: Record<string, any>;
221
- /**
222
- * Current request path, adjusted relative to the mount point during router nesting.
223
- */
224
- path: string;
225
- /**
226
- * HTTP method (GET, POST, PUT, etc.).
227
- */
228
- readonly method: string;
229
- /**
230
- * Accumulated mount path from nested routers.
231
- */
232
- mountPath: string;
233
- /**
234
- * Response accumulator — set status/headers before returning a plain value.
235
- */
236
- readonly response: RoutupResponse;
237
- /**
238
- * Whether a response has been produced.
239
- */
240
- dispatched: boolean;
241
- /**
242
- * Error that occurred during dispatch, if any.
243
- */
244
- error?: RoutupError;
245
- /**
246
- * Router stack for nesting tracking.
247
- * Used internally by router options resolution.
248
- */
249
- routerPath: RouterPathNode[];
250
- /**
251
- * Abort signal for cooperative cancellation.
252
- *
253
- * When a `timeout` router option is set, this signal aborts after the
254
- * specified duration. Handlers can pass it to fetch(), streams, or other
255
- * AbortSignal-aware APIs.
256
- */
257
- signal: AbortSignal;
258
- /**
259
- * Collected allowed methods for the current path (used for OPTIONS / 405 responses).
260
- */
261
- methodsAllowed: Set<string>;
262
- /**
263
- * Set the continuation function for this event.
264
- *
265
- * Replaces the current continuation. The provided function receives
266
- * an optional error and may return any value — it will be converted
267
- * to a `Response` via `toResponse()`.
268
- *
269
- * Passing `undefined` clears the continuation function.
270
- */
271
- setNext(fn?: NextFn): void;
272
- /**
273
- * Build a public RoutupEvent from the current dispatch state.
274
- *
275
- * Creates a lightweight snapshot with shared references (store, response, headers)
276
- * and pre-resolved router options. This is the event passed to handler functions.
277
- *
278
- * @param signal - Optional AbortSignal override. When provided, the built event
279
- * uses this signal instead of the dispatcher event's own signal.
280
- * Used by per-handler timeout to provide a handler-scoped signal.
281
- */
282
- build(signal?: AbortSignal): RoutupEvent;
283
- }
284
- interface IDispatcher {
285
- dispatch(event: IDispatcherEvent): Promise<Response | undefined>;
286
- }
287
- //#endregion
288
- //#region src/hook/types.d.ts
289
- type HookErrorListener = (event: IDispatcherEvent) => Promise<unknown> | unknown;
290
- type HookDefaultListener = (event: IDispatcherEvent) => Promise<unknown> | unknown;
291
- type HookListener = HookErrorListener | HookDefaultListener;
292
- type HookUnsubscribeFn = () => void;
293
- interface IHooks {
294
- addListener(name: HookName, fn: HookListener, priority?: number): HookUnsubscribeFn;
295
- removeListener(name: HookName): void;
296
- removeListener(name: HookName, fn: HookListener): void;
297
- removeListener(name: HookName, fn?: HookListener): void;
298
- clone(): IHooks;
299
- trigger(name: HookName, event: IDispatcherEvent): Promise<void>;
300
- }
301
- //#endregion
302
- //#region src/path/type.d.ts
303
- type PathMatcherOptions = PathToRegexpOptions & ParseOptions;
304
- type PathMatcherExecResult = {
305
- path: string;
306
- params: Record<string, any>;
307
- };
308
- type Path = string;
309
- //#endregion
310
- //#region src/path/matcher.d.ts
311
- declare class PathMatcher {
312
- protected path: Path;
313
- protected regexp: RegExp;
314
- protected regexpKeys: Key[];
315
- protected regexpOptions: PathMatcherOptions;
316
- constructor(path: Path, options?: PathMatcherOptions);
317
- test(path: string): boolean;
318
- exec(path: string): PathMatcherExecResult | undefined;
319
- }
320
- //#endregion
321
- //#region src/path/utils.d.ts
322
- declare function isPath(input: unknown): input is Path;
323
- //#endregion
324
- //#region src/handler/constants.d.ts
325
- declare const HandlerType: {
326
- readonly CORE: "core";
327
- readonly ERROR: "error";
328
- };
329
- type HandlerType = typeof HandlerType[keyof typeof HandlerType];
330
- declare const HandlerSymbol: unique symbol;
331
- //#endregion
332
- //#region src/handler/types-base.d.ts
333
- type HandlerBaseOptions = {
334
- method?: Uppercase<MethodName> | Lowercase<MethodName>;
335
- path?: Path;
336
- /**
337
- * Per-handler timeout in milliseconds.
338
- *
339
- * Overrides the router's `handlerTimeout` default. Whether this value
340
- * can extend or only narrow the default is controlled by the router's
341
- * `handlerTimeoutOverridable` option.
342
- */
343
- timeout?: number;
344
- onError?: HookErrorListener;
345
- onBefore?: HookDefaultListener;
346
- onAfter?: HookDefaultListener;
347
- };
348
- //#endregion
349
- //#region src/handler/error/types.d.ts
350
- type ErrorHandler = (error: RoutupError, event: IRoutupEvent) => unknown | Promise<unknown>;
351
- type ErrorHandlerOptions = HandlerBaseOptions & {
352
- type: typeof HandlerType.ERROR;
353
- fn: ErrorHandler;
354
- };
355
- //#endregion
356
- //#region src/handler/error/define.d.ts
357
- /**
358
- * Create an error handler.
359
- *
360
- * Error handlers receive errors thrown by preceding handlers in the pipeline.
361
- *
362
- * @param input - Handler function `(error, event) => value` or options object `{ fn, path? }`
363
- *
364
- * @example
365
- * ```typescript
366
- * router.use(defineErrorHandler((error, event) => {
367
- * return { message: error.message };
368
- * }));
369
- * ```
370
- */
371
- declare function defineErrorHandler(input: Omit<ErrorHandlerOptions, 'type'>): Handler;
372
- declare function defineErrorHandler(input: ErrorHandler): Handler;
373
- //#endregion
374
- //#region src/handler/types.d.ts
375
- type HandlerOptions = CoreHandlerOptions | ErrorHandlerOptions;
376
- //#endregion
377
- //#region src/handler/module.d.ts
378
- declare class Handler implements IDispatcher {
379
- protected config: HandlerOptions;
380
- protected hooks: IHooks;
381
- protected pathMatcher: PathMatcher | undefined;
382
- readonly method: MethodName | undefined;
383
- constructor(handler: HandlerOptions);
384
- get type(): "error" | "core";
385
- get path(): string | undefined;
386
- dispatch(event: IDispatcherEvent): Promise<Response | undefined>;
387
- matchPath(path: string): boolean;
388
- /**
389
- * Resolve a handler's return value into the final value handed to `toResponse`.
390
- *
391
- * Contract:
392
- * - non-undefined value → return as-is (becomes the response)
393
- * - `undefined` + `event.next()` was called → forward downstream result
394
- * - `undefined` + `event.next()` not yet called → wait until either `next()` is
395
- * invoked (e.g. from an async callback) or `signal` aborts. A global or
396
- * per-handler timeout aborts `signal` and surfaces as 408. With no timeout
397
- * configured and no eventual `next()` call, the request hangs by design.
398
- */
399
- protected resolveHandlerResult(invocation: unknown | Promise<unknown>, handlerEvent: IRoutupEvent): Promise<unknown>;
400
- protected executeWithTimeout(fn: () => unknown | Promise<unknown>, routerOptions: RouterOptions, controller?: AbortController): Promise<unknown>;
401
- protected resolveTimeout(routerOptions: RouterOptions): number | undefined;
402
- protected mountHooks(): void;
403
- }
404
- //#endregion
405
- //#region src/handler/core/types.d.ts
406
- type CoreHandler = (event: IRoutupEvent) => unknown | Promise<unknown>;
407
- type CoreHandlerOptions = HandlerBaseOptions & {
408
- type: typeof HandlerType.CORE;
409
- fn: CoreHandler;
410
- };
411
- //#endregion
412
- //#region src/handler/core/define.d.ts
413
- /**
414
- * Create a request handler.
415
- *
416
- * @param input - Handler function `(event) => value` or options object `{ fn, path?, method? }`
417
- *
418
- * @example
419
- * ```typescript
420
- * // Shorthand — function only
421
- * router.get('/', defineCoreHandler((event) => 'Hello'));
422
- *
423
- * // Verbose — with path and method
424
- * router.use(defineCoreHandler({
425
- * path: '/users/:id',
426
- * method: 'GET',
427
- * fn: (event) => ({ id: event.params.id }),
428
- * }));
429
- * ```
430
- */
431
- declare function defineCoreHandler(input: Omit<CoreHandlerOptions, 'type'>): Handler;
432
- declare function defineCoreHandler(input: CoreHandler): Handler;
433
- //#endregion
434
- //#region src/handler/adapters/node/types.d.ts
435
- type NodeHandler = (req: IncomingMessage, res: ServerResponse) => unknown | Promise<unknown>;
436
- type NodeMiddleware = (req: IncomingMessage, res: ServerResponse, next: (err?: unknown) => void) => unknown | Promise<unknown>;
437
- //#endregion
438
- //#region src/handler/adapters/node/define.d.ts
439
- /**
440
- * Wraps a Node.js `(req, res)` handler for use in the routup pipeline.
441
- *
442
- * @example
443
- * ```typescript
444
- * import { fromNodeHandler } from 'routup/node';
445
- *
446
- * router.use(fromNodeHandler((req, res) => {
447
- * res.end('Hello');
448
- * }));
449
- * ```
450
- */
451
- declare function fromNodeHandler(handler: NodeHandler): Handler;
452
- /**
453
- * Wraps a Node.js `(req, res, next)` middleware for use in the routup pipeline.
454
- *
455
- * @example
456
- * ```typescript
457
- * import cors from 'cors';
458
- * import { fromNodeMiddleware } from 'routup/node';
459
- *
460
- * router.use(fromNodeMiddleware(cors()));
461
- * ```
462
- */
463
- declare function fromNodeMiddleware(handler: NodeMiddleware): Handler;
464
- //#endregion
465
- //#region src/handler/adapters/web/types.d.ts
466
- /**
467
- * A plain function that follows the Web Fetch API signature.
468
- * Compatible with any framework that exposes a fetch-style entry point.
469
- */
470
- interface WebHandler {
471
- (request: Request): Response | Promise<Response>;
472
- }
473
- /**
474
- * An object with a `fetch` method (e.g. another router, Hono app, etc.).
475
- */
476
- interface WebHandlerProvider {
477
- fetch(request: Request): Response | Promise<Response>;
478
- }
479
- //#endregion
480
- //#region src/handler/adapters/web/define.d.ts
481
- /**
482
- * Create a handler from a Web Fetch API-compatible function or object.
483
- *
484
- * Wraps an external app (e.g. Hono, another Router) so it can be mounted
485
- * via `router.use()`. The original request is passed through as-is.
486
- *
487
- * @param input - Fetch function `(request) => Response` or object with a `fetch` method
488
- *
489
- * @experimental
490
- *
491
- * @example
492
- * ```ts
493
- * // Mount an object with a fetch method
494
- * router.use('/api', fromWebHandler(honoApp));
495
- *
496
- * // Mount a plain fetch function
497
- * router.use('/proxy', fromWebHandler((req) => fetch(req)));
498
- * ```
499
- */
500
- declare function fromWebHandler(input: WebHandler): Handler;
501
- declare function fromWebHandler(input: WebHandlerProvider): Handler;
502
- //#endregion
503
- //#region src/handler/adapters/web/is.d.ts
504
- declare function isWebHandlerProvider(input: unknown): input is WebHandlerProvider;
505
- declare function isWebHandler(input: unknown): input is WebHandler;
506
- //#endregion
507
- //#region src/handler/is.d.ts
508
- declare function isHandlerOptions(input: unknown): input is HandlerOptions;
509
- declare function isHandler(input: unknown): input is Handler;
510
- //#endregion
511
- //#region src/handler/utils.d.ts
512
- /**
513
- * Build a `PathMatcher` for a handler-side path.
514
- *
515
- * Returns `undefined` when no path is supplied. The `end` flag controls
516
- * whether the matcher requires a full match (`true` for method handlers
517
- * matching exact routes) or accepts a prefix (`false` for middleware).
518
- */
519
- declare function buildHandlerPathMatcher(path: Path | undefined, end: boolean): PathMatcher | undefined;
520
- /**
521
- * Match a request method against a handler's bound method.
522
- *
523
- * - When the handler has no method bound, matches every request method.
524
- * - Otherwise matches when the request method is the same.
525
- * - HEAD requests additionally match GET handlers.
526
- */
527
- declare function matchHandlerMethod(handlerMethod: MethodName | undefined, requestMethod: MethodName): boolean;
528
- //#endregion
529
- //#region src/plugin/error/constants.d.ts
530
- declare const PluginErrorCode: {
531
- readonly PLUGIN: "PLUGIN";
532
- readonly NOT_INSTALLED: "PLUGIN_NOT_INSTALLED";
533
- readonly ALREADY_INSTALLED: "PLUGIN_ALREADY_INSTALLED";
534
- readonly INSTALL: "PLUGIN_INSTALL";
535
- };
536
- type PluginErrorCode = typeof PluginErrorCode[keyof typeof PluginErrorCode];
537
- //#endregion
538
- //#region src/plugin/error/module.d.ts
539
- declare class PluginError extends RoutupError {
540
- constructor(input?: HTTPErrorInput);
541
- }
542
- //#endregion
543
- //#region src/plugin/error/is.d.ts
544
- declare function isPluginError(input: unknown): input is PluginError;
545
- //#endregion
546
- //#region src/plugin/error/sub/already-installed.d.ts
547
- declare class PluginAlreadyInstalledError extends PluginError {
548
- readonly pluginName: string;
549
- constructor(pluginName: string);
550
- }
551
- //#endregion
552
- //#region src/plugin/error/sub/install.d.ts
553
- declare class PluginInstallError extends PluginError {
554
- readonly pluginName: string;
555
- constructor(pluginName: string, cause?: Error);
556
- }
557
- //#endregion
558
- //#region src/plugin/error/sub/not-installed.d.ts
559
- declare class PluginNotInstalledError extends PluginError {
560
- readonly pluginName: string;
561
- readonly helperName: string;
562
- constructor(pluginName: string, helperName: string);
563
- }
564
- //#endregion
565
- //#region src/plugin/types.d.ts
566
- type PluginInstallFn = (router: IRouter) => any;
567
- type Plugin = {
568
- /**
569
- * The name of the plugin.
570
- */
571
- name: string;
572
- /**
573
- * The version of the plugin (semver).
574
- */
575
- version?: string;
576
- /**
577
- * The installation function called on registration.
578
- */
579
- install: PluginInstallFn;
580
- };
581
- type PluginInstallContext = {
582
- /**
583
- * By specifying a path, the plugin will be installed as a child router.
584
- */
585
- path?: Path;
586
- };
587
- //#endregion
588
- //#region src/plugin/is.d.ts
589
- declare function isPlugin(input: unknown): input is Plugin;
590
- //#endregion
591
- //#region src/utils/etag/types.d.ts
592
- type EtagOptions = {
593
- /**
594
- * Create a weak ETag?
595
- * Output is prefixed with: /W
596
- */
597
- weak?: boolean;
598
- /**
599
- * Threshold of bytes from which an etag is generated.
600
- *
601
- * default: undefined
602
- */
603
- threshold?: number;
604
- };
605
- type EtagFn = (body: string, size?: number) => Promise<string | undefined>;
606
- type EtagInput = boolean | EtagOptions | EtagFn;
607
- //#endregion
608
- //#region src/utils/trust-proxy/type.d.ts
609
- type TrustProxyFn = (address: string, hop: number) => boolean;
610
- type TrustProxyInput = boolean | number | string | string[] | TrustProxyFn;
611
- //#endregion
612
- //#region src/router/constants.d.ts
613
- declare const RouterPipelineStep: {
614
- readonly START: 0;
615
- readonly LOOKUP: 1;
616
- readonly CHILD_BEFORE: 2;
617
- readonly CHILD_DISPATCH: 3;
618
- readonly CHILD_AFTER: 4;
619
- readonly FINISH: 5;
620
- };
621
- type RouterPipelineStep = typeof RouterPipelineStep[keyof typeof RouterPipelineStep];
622
- declare const RouterStackEntryType: {
623
- readonly ROUTER: "router";
624
- readonly HANDLER: "handler";
625
- };
626
- type RouterStackEntryType = typeof RouterStackEntryType[keyof typeof RouterStackEntryType];
627
- //#endregion
628
- //#region src/router/types.d.ts
629
- type RouterOptions = {
630
- path?: Path;
631
- name?: string;
632
- /**
633
- * Global request timeout in milliseconds.
634
- *
635
- * Applies to the entire dispatch pipeline in `fetch()`. When exceeded,
636
- * the request is aborted and a 408 response is returned. The AbortSignal
637
- * on the event is also aborted for cooperative cancellation.
638
- */
639
- timeout?: number;
640
- /**
641
- * Default per-handler timeout in milliseconds.
642
- *
643
- * Applies individually to each handler's `fn()` execution. Handlers can
644
- * override this value via their own `timeout` option — see
645
- * `handlerTimeoutOverridable` to control whether overrides can extend
646
- * or only narrow this default.
647
- */
648
- handlerTimeout?: number;
649
- /**
650
- * Whether handlers can extend the `handlerTimeout` default.
651
- *
652
- * When `false` (default), a handler's `timeout` is clamped to
653
- * `Math.min(handlerTimeout, handler.timeout)`. When `true`, the
654
- * handler's `timeout` fully replaces the router default.
655
- */
656
- handlerTimeoutOverridable?: boolean;
657
- subdomainOffset: number;
658
- proxyIpMax: number;
659
- etag: EtagFn;
660
- trustProxy: TrustProxyFn;
661
- };
662
- type RouterOptionsInput = Omit<Partial<RouterOptions>, 'etag' | 'trustProxy'> & {
663
- etag?: EtagInput;
664
- trustProxy?: TrustProxyInput;
665
- hooks?: IHooks;
666
- plugins?: Map<string, string | undefined>;
667
- };
668
- type RouterPathNode = {
669
- readonly name?: string;
670
- readonly options: Partial<RouterOptions>;
671
- };
672
- type StackRouterEntry = {
673
- type: typeof RouterStackEntryType.ROUTER;
674
- data: IRouter;
675
- /**
676
- * Original mount path the entry was registered with, retained so
677
- * `Router.clone()` can re-register the entry via the public API.
678
- */
679
- path?: Path;
680
- /**
681
- * Mount-specific path matcher.
682
- *
683
- * Set when the router was mounted under a path (e.g. `parent.use('/api', child)`).
684
- * When undefined, the lookup falls back to the router's own intrinsic matcher.
685
- */
686
- pathMatcher?: PathMatcher;
687
- };
688
- type StackHandlerEntry = {
689
- type: typeof RouterStackEntryType.HANDLER;
690
- data: Handler;
691
- /**
692
- * Original mount path the entry was registered with, retained so
693
- * `Router.clone()` can re-register the entry via the public API.
694
- */
695
- path?: Path;
696
- /**
697
- * Mount-specific path matcher.
698
- *
699
- * Set when the handler was registered under a path (e.g.
700
- * `parent.use('/api', handler)`). When undefined, the lookup falls back
701
- * to the handler's own intrinsic matcher.
702
- */
703
- pathMatcher?: PathMatcher;
704
- /**
705
- * Mount-specific HTTP method.
706
- *
707
- * Set when the handler was registered via a method-bound shortcut
708
- * (e.g. `router.get(handler)` sets this to `GET`). When undefined,
709
- * dispatch falls back to the handler's own intrinsic method.
710
- */
711
- method?: MethodName;
712
- };
713
- type StackEntry = StackRouterEntry | StackHandlerEntry;
714
- type RouterPipelineContext = {
715
- step: RouterPipelineStep;
716
- event: IDispatcherEvent;
717
- stackIndex: number;
718
- response?: Response;
719
- };
720
- interface IRouter extends IDispatcher {
721
- /**
722
- * Optional label for the router instance.
723
- */
724
- readonly name?: string;
725
- /**
726
- * Public entry point — processes a request through the pipeline
727
- * and returns a Response (with 404/500 fallbacks).
728
- */
729
- fetch(request: RoutupRequest): Promise<Response>;
730
- /**
731
- * Test if a path matches this router's mount path.
732
- */
733
- matchPath(path: string): boolean;
734
- /**
735
- * Return a new router that mirrors this one but owns independent
736
- * mountable state — fresh stack of shallow-copied entries (handlers and
737
- * child routers shared by reference), fresh `Hooks` seeded with the
738
- * current listeners, shallow copy of options, and a fresh plugins map.
739
- *
740
- * Intended for mounting the same logical router under multiple paths
741
- * without sharing mutable state across mount points.
742
- */
743
- clone(): IRouter;
744
- /**
745
- * Check if a plugin with the given name is installed on this router.
746
- */
747
- hasPlugin(name: string): boolean;
748
- /**
749
- * Get the version of an installed plugin by name on this router,
750
- * or `undefined` if the plugin is not installed here.
751
- */
752
- getPluginVersion(name: string): string | undefined;
753
- /**
754
- * Register a handler, router, or plugin.
755
- * When a path is provided, the item is mounted at that path.
756
- */
757
- use(router: IRouter): this;
758
- use(handler: Handler | HandlerOptions): this;
759
- use(plugin: Plugin): this;
760
- use(path: Path, router: IRouter): this;
761
- use(path: Path, handler: Handler | HandlerOptions): this;
762
- use(path: Path, plugin: Plugin): this;
763
- /** Register GET handler(s). */
764
- get(...handlers: (Handler | HandlerOptions)[]): this;
765
- get(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
766
- /** Register POST handler(s). */
767
- post(...handlers: (Handler | HandlerOptions)[]): this;
768
- post(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
769
- /** Register PUT handler(s). */
770
- put(...handlers: (Handler | HandlerOptions)[]): this;
771
- put(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
772
- /** Register PATCH handler(s). */
773
- patch(...handlers: (Handler | HandlerOptions)[]): this;
774
- patch(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
775
- /** Register DELETE handler(s). */
776
- delete(...handlers: (Handler | HandlerOptions)[]): this;
777
- delete(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
778
- /** Register HEAD handler(s). */
779
- head(...handlers: (Handler | HandlerOptions)[]): this;
780
- head(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
781
- /** Register OPTIONS handler(s). */
782
- options(...handlers: (Handler | HandlerOptions)[]): this;
783
- options(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
784
- /**
785
- * Add a hook listener.
786
- */
787
- on(name: typeof HookName.REQUEST | typeof HookName.RESPONSE | typeof HookName.CHILD_DISPATCH_BEFORE | typeof HookName.CHILD_DISPATCH_AFTER, fn: HookDefaultListener): HookUnsubscribeFn;
788
- on(name: typeof HookName.CHILD_MATCH, fn: HookDefaultListener): HookUnsubscribeFn;
789
- on(name: typeof HookName.ERROR, fn: HookErrorListener): HookUnsubscribeFn;
790
- /**
791
- * Remove a specific or all hook listeners for the given hook name.
792
- */
793
- off(name: HookName): this;
794
- off(name: HookName, fn: HookListener): this;
795
- }
796
- //#endregion
797
- //#region src/dispatcher/module.d.ts
798
- declare class DispatcherEvent implements IDispatcherEvent {
799
- readonly request: RoutupRequest;
800
- params: Record<string, any>;
801
- path: string;
802
- readonly method: string;
803
- /**
804
- * Collected allowed methods (for OPTIONS).
805
- */
806
- methodsAllowed: Set<string>;
807
- mountPath: string;
808
- error?: RoutupError;
809
- routerPath: RouterPathNode[];
810
- protected _dispatched: boolean;
811
- protected _response?: RoutupResponse;
812
- protected _store?: Record<string | symbol, unknown>;
813
- /**
814
- * Cached parsed URL (avoids double-parsing).
815
- */
816
- protected _url: InstanceType<typeof FastURL>;
817
- /**
818
- * Continuation function for middleware onion model.
819
- */
820
- protected _next?: (event: IRoutupEvent, error?: Error) => Promise<Response | undefined>;
821
- protected _signal?: AbortSignal;
822
- protected _signalCleanup?: () => void;
823
- /**
824
- * Whether _next has already been called (guard against double-invocation).
825
- */
826
- protected _nextCalled: boolean;
827
- /**
828
- * The cached result of the next handler.
829
- */
830
- protected _nextResult?: Promise<Response | undefined>;
831
- constructor(request: RoutupRequest);
832
- get response(): RoutupResponse;
833
- get signal(): AbortSignal;
834
- set signal(value: AbortSignal);
835
- get dispatched(): boolean;
836
- set dispatched(value: boolean);
837
- protected next(event: IRoutupEvent, error?: Error): Promise<Response | undefined>;
838
- setNext(fn?: NextFn): void;
839
- build(signal?: AbortSignal): RoutupEvent;
840
- protected get store(): Record<string | symbol, unknown>;
841
- protected resolveOptions(): RouterOptions;
842
- }
843
- //#endregion
844
- //#region src/router/module.d.ts
845
- declare class Router implements IRouter {
846
- /**
847
- * A label for the router instance.
848
- */
849
- readonly name?: string;
850
- /**
851
- * Array of mounted layers, routes & routers, each tagged by kind so the
852
- * dispatch loop can discriminate without `isRouterInstance`/`isHandler`
853
- * runtime checks.
854
- *
855
- * @protected
856
- */
857
- protected stack: StackEntry[];
858
- /**
859
- * Path matcher for the current mount path.
860
- *
861
- * @protected
862
- */
863
- protected pathMatcher: PathMatcher | undefined;
864
- /**
865
- * Lifecycle hook registry.
866
- *
867
- * @protected
868
- */
869
- protected hooks: IHooks;
870
- /**
871
- * Normalized options for this router instance.
872
- */
873
- protected _options: Partial<RouterOptions>;
874
- /**
875
- * Registry of installed plugins (name → version) on this router.
876
- *
877
- * @protected
878
- */
879
- protected plugins: Map<string, string | undefined>;
880
- constructor(input?: RouterOptionsInput);
881
- matchPath(path: string): boolean;
882
- /**
883
- * Public entry point — creates a DispatcherEvent from the request,
884
- * runs the pipeline, and returns a Response (with 404/500 fallbacks).
885
- */
886
- fetch(request: RoutupRequest): Promise<Response>;
887
- protected buildFallbackResponse(request: RoutupRequest, event: IDispatcherEvent, status: number, message: string): Response;
888
- protected executePipelineStep(context: RouterPipelineContext): Promise<void>;
889
- protected executePipelineStepStart(context: RouterPipelineContext): Promise<void>;
890
- protected executePipelineStepLookup(context: RouterPipelineContext): Promise<void>;
891
- protected executePipelineStepChildBefore(context: RouterPipelineContext): Promise<void>;
892
- protected executePipelineStepChildAfter(context: RouterPipelineContext): Promise<void>;
893
- protected executePipelineStepChildDispatch(context: RouterPipelineContext): Promise<void>;
894
- protected executePipelineStepFinish(context: RouterPipelineContext): Promise<void>;
895
- dispatch(event: IDispatcherEvent): Promise<Response | undefined>;
896
- delete(...handlers: (Handler | HandlerOptions)[]): this;
897
- delete(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
898
- get(...handlers: (Handler | HandlerOptions)[]): this;
899
- get(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
900
- post(...handlers: (Handler | HandlerOptions)[]): this;
901
- post(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
902
- put(...handlers: (Handler | HandlerOptions)[]): this;
903
- put(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
904
- patch(...handlers: (Handler | HandlerOptions)[]): this;
905
- patch(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
906
- head(...handlers: (Handler | HandlerOptions)[]): this;
907
- head(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
908
- options(...handlers: (Handler | HandlerOptions)[]): this;
909
- options(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
910
- protected useForMethod(method: MethodName, ...input: (Path | Handler | HandlerOptions)[]): void;
911
- use(router: IRouter): this;
912
- use(handler: Handler | HandlerOptions): this;
913
- use(plugin: Plugin): this;
914
- use(path: Path, router: IRouter): this;
915
- use(path: Path, handler: Handler | HandlerOptions): this;
916
- use(path: Path, plugin: Plugin): this;
917
- /**
918
- * Check if a plugin with the given name is installed on this router.
919
- */
920
- hasPlugin(name: string): boolean;
921
- /**
922
- * Get the version of an installed plugin by name on this router,
923
- * or `undefined` if the plugin is not installed here.
924
- */
925
- getPluginVersion(name: string): string | undefined;
926
- protected install(plugin: Plugin, context?: PluginInstallContext): this;
927
- /**
928
- * Return a new `Router` that mirrors this one but owns independent
929
- * mountable state.
930
- *
931
- * The new router has:
932
- * - a fresh `stack` array of shallow-copied entries (handlers and child
933
- * routers are shared by reference; only the wrapping entries are new)
934
- * - the same `pathMatcher` reference (it is stateless)
935
- * - a fresh `Hooks` instance seeded with the current listeners
936
- * - a shallow copy of `_options`
937
- * - a fresh `plugins` map with the same entries
938
- *
939
- * Use this when the same logical router needs to be mounted under
940
- * multiple paths — each mount can receive its own clone so subsequent
941
- * mutations on one mount do not bleed into the others.
942
- */
943
- clone(): IRouter;
944
- /**
945
- * Add a hook listener.
946
- *
947
- * @param name
948
- * @param fn
949
- */
950
- on(name: typeof HookName.REQUEST | typeof HookName.RESPONSE | typeof HookName.CHILD_DISPATCH_BEFORE | typeof HookName.CHILD_DISPATCH_AFTER, fn: HookDefaultListener, priority?: number): HookUnsubscribeFn;
951
- on(name: typeof HookName.CHILD_MATCH, fn: HookDefaultListener, priority?: number): HookUnsubscribeFn;
952
- on(name: typeof HookName.ERROR, fn: HookErrorListener, priority?: number): HookUnsubscribeFn;
953
- /**
954
- * Remove single or all hook listeners.
955
- *
956
- * @param name
957
- */
958
- off(name: HookName): this;
959
- off(name: HookName, fn: HookListener): this;
960
- }
961
- //#endregion
962
- //#region src/error/create.d.ts
963
- /**
964
- * Create an internal error object by
965
- * - an existing RoutupError (returned as-is)
966
- * - an HTTPError (wrapped into a RoutupError preserving status)
967
- * - an Error (wrapped preserving message and cause)
968
- * - an options object (status, message, etc.)
969
- * - a message string
970
- *
971
- * @param input
972
- */
973
- declare function createError(input: HTTPErrorInput | unknown): RoutupError;
974
- //#endregion
975
- //#region src/error/is.d.ts
976
- declare function isError(input: unknown): input is RoutupError;
977
- //#endregion
978
- //#region src/response/helpers/cache.d.ts
979
- type ResponseCacheHeadersOptions = {
980
- maxAge?: number;
981
- modifiedTime?: string | Date;
982
- cacheControls?: string[];
983
- };
984
- declare function setResponseCacheHeaders(event: IRoutupEvent, options?: ResponseCacheHeadersOptions): void;
985
- //#endregion
986
- //#region src/response/helpers/event-stream/types.d.ts
987
- /**
988
- * https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format
989
- */
990
- type EventStreamMessage = {
991
- /**
992
- * The event ID to set the EventSource object's last event ID value.
993
- */
994
- id?: string;
995
- /**
996
- * The reconnection time.
997
- * If the connection to the server is lost, the browser will wait for the specified time before attempting to reconnect.
998
- * This must be an integer, specifying the reconnection time in milliseconds.
999
- */
1000
- retry?: number;
1001
- /**
1002
- * The data field for the message.
1003
- */
1004
- data: string;
1005
- /**
1006
- * A string identifying the type of event described.
1007
- */
1008
- event?: string;
1009
- };
1010
- type EventStreamListener<T = any> = (err: Error | null, data: T) => void | Promise<void>;
1011
- //#endregion
1012
- //#region src/response/helpers/event-stream/module.d.ts
1013
- type EventStreamOptions = {
1014
- maxMessageSize?: number;
1015
- };
1016
- type EventStreamHandle = {
1017
- write(message: string | EventStreamMessage): boolean;
1018
- end(): void;
1019
- response: Response;
1020
- };
1021
- declare function createEventStream(event: IRoutupEvent, options?: EventStreamOptions): EventStreamHandle;
1022
- //#endregion
1023
- //#region src/response/helpers/event-stream/utils.d.ts
1024
- declare function serializeEventStreamMessage(message: EventStreamMessage): string;
1025
- //#endregion
1026
- //#region src/response/helpers/header.d.ts
1027
- declare function appendResponseHeader(event: IRoutupEvent, name: string, value: string | string[]): void;
1028
- declare function appendResponseHeaderDirective(event: IRoutupEvent, name: string, value: string | string[]): void;
1029
- //#endregion
1030
- //#region src/response/helpers/header-disposition.d.ts
1031
- declare function setResponseHeaderAttachment(event: IRoutupEvent, filename?: string): void;
1032
- declare function setResponseHeaderInline(event: IRoutupEvent, filename?: string): void;
1033
- //#endregion
1034
- //#region src/response/helpers/header-content-type.d.ts
1035
- declare function setResponseHeaderContentType(event: IRoutupEvent, input: string, ifNotExists?: boolean): void;
1036
- //#endregion
1037
- //#region src/response/helpers/send-accepted.d.ts
1038
- declare function sendAccepted(event: IRoutupEvent, data?: unknown): Promise<Response>;
1039
- //#endregion
1040
- //#region src/response/helpers/send-created.d.ts
1041
- declare function sendCreated(event: IRoutupEvent, data?: unknown): Promise<Response>;
1042
- //#endregion
1043
- //#region src/response/helpers/send-file.d.ts
1044
- type SendFileContentOptions = {
1045
- end?: number;
1046
- start?: number;
1047
- };
1048
- /**
1049
- * File metadata used by {@link sendFile}. All fields are optional, but each
1050
- * missing field disables related response features:
1051
- *
1052
- * - `size` — without it, range requests, `Accept-Ranges`, `Content-Length`,
1053
- * `ETag`, and `Last-Modified` are all omitted (the response is sent
1054
- * without HTTP-level caching or seekability).
1055
- * - `mtime` — without it, `Last-Modified` is omitted and the `ETag` is not
1056
- * emitted (`ETag` requires both `size` and `mtime`).
1057
- * - `name` — falls back to `SendFileOptions.name` when set; if both are
1058
- * missing, no `Content-Disposition` or extension-derived
1059
- * `Content-Type` is set.
1060
- */
1061
- type SendFileStats = {
1062
- size?: number;
1063
- mtime?: Date | number | string;
1064
- name?: string;
1065
- };
1066
- type SendFileDisposition = 'attachment' | 'inline';
1067
- type SendFileContent = ReadableStream | ArrayBuffer | Uint8Array;
1068
- type SendFileOptions = {
1069
- stats: (() => Promise<SendFileStats> | SendFileStats) | SendFileStats;
1070
- content: (options: SendFileContentOptions) => Promise<SendFileContent> | SendFileContent;
1071
- /**
1072
- * @deprecated Use `disposition: 'attachment'` instead. Kept for backwards
1073
- * compatibility — when `disposition` is set, it takes precedence.
1074
- */
1075
- attachment?: boolean;
1076
- disposition?: SendFileDisposition;
1077
- name?: string;
1078
- };
1079
- declare function sendFile(event: IRoutupEvent, options: SendFileOptions): Promise<Response>;
1080
- //#endregion
1081
- //#region src/response/helpers/send-format.d.ts
1082
- type ResponseFormatHandler = () => Response | unknown;
1083
- type ResponseFormats = {
1084
- default: ResponseFormatHandler;
1085
- [key: string]: ResponseFormatHandler;
1086
- };
1087
- declare function sendFormat(event: IRoutupEvent, input: ResponseFormats): Response | unknown | undefined;
1088
- //#endregion
1089
- //#region src/response/helpers/send-redirect.d.ts
1090
- declare function sendRedirect(event: IRoutupEvent, location: string, statusCode?: number): Response;
1091
- //#endregion
1092
- //#region src/response/helpers/send-stream.d.ts
1093
- declare function sendStream(event: IRoutupEvent, stream: ReadableStream): Response;
1094
- //#endregion
1095
- //#region src/response/helpers/utils.d.ts
1096
- declare function setResponseContentTypeByFileName(event: IRoutupEvent, fileName: string): void;
1097
- //#endregion
1098
- //#region src/response/to-response.d.ts
1099
- declare function toResponse(value: unknown, event: IRoutupEvent): Promise<Response | undefined>;
1100
- //#endregion
1101
- //#region src/request/helpers/cache.d.ts
1102
- declare function isRequestCacheable(event: IRoutupEvent, modifiedTime: string | Date): boolean;
1103
- //#endregion
1104
- //#region src/request/helpers/header.d.ts
1105
- declare function getRequestHeader(event: IRoutupEvent, name: string): string | null;
1106
- //#endregion
1107
- //#region src/request/helpers/header-accept.d.ts
1108
- declare function getRequestAcceptableContentTypes(event: IRoutupEvent): string[];
1109
- declare function getRequestAcceptableContentType(event: IRoutupEvent, input?: string | string[]): string | undefined;
1110
- //#endregion
1111
- //#region src/request/helpers/header-accept-charset.d.ts
1112
- declare function getRequestAcceptableCharsets(event: IRoutupEvent): string[];
1113
- declare function getRequestAcceptableCharset(event: IRoutupEvent, input: string | string[]): string | undefined;
1114
- //#endregion
1115
- //#region src/request/helpers/header-accept-encoding.d.ts
1116
- declare function getRequestAcceptableEncodings(event: IRoutupEvent): string[];
1117
- declare function getRequestAcceptableEncoding(event: IRoutupEvent, input: string | string[]): string | undefined;
1118
- //#endregion
1119
- //#region src/request/helpers/header-accept-language.d.ts
1120
- declare function getRequestAcceptableLanguages(event: IRoutupEvent): string[];
1121
- declare function getRequestAcceptableLanguage(event: IRoutupEvent, input?: string | string[]): string | undefined;
1122
- //#endregion
1123
- //#region src/request/helpers/header-content-type.d.ts
1124
- declare function matchRequestContentType(event: IRoutupEvent, contentType: string): boolean;
1125
- //#endregion
1126
- //#region src/request/helpers/hostname.d.ts
1127
- type RequestHostNameOptions = {
1128
- trustProxy?: TrustProxyInput;
1129
- };
1130
- declare function getRequestHostName(event: IRoutupEvent, options?: RequestHostNameOptions): string | undefined;
1131
- //#endregion
1132
- //#region src/request/helpers/ip.d.ts
1133
- type RequestIpOptions = {
1134
- trustProxy?: TrustProxyInput;
1135
- };
1136
- /**
1137
- * Get the client IP address from the request.
1138
- *
1139
- * When `trustProxy` is configured, walks the `X-Forwarded-For` chain
1140
- * and returns the rightmost untrusted address (the actual client IP).
1141
- * Falls back to `event.request.ip` (the direct connection IP).
1142
- */
1143
- declare function getRequestIP(event: IRoutupEvent, options?: RequestIpOptions): string | undefined;
1144
- //#endregion
1145
- //#region src/request/helpers/negotiator.d.ts
1146
- declare function useRequestNegotiator(event: IRoutupEvent): Negotiator;
1147
- //#endregion
1148
- //#region src/request/helpers/protocol.d.ts
1149
- type RequestProtocolOptions = {
1150
- trustProxy?: TrustProxyInput;
1151
- default?: string;
1152
- };
1153
- declare function getRequestProtocol(event: IRoutupEvent, options?: RequestProtocolOptions): string;
1154
- //#endregion
1155
- //#region src/router/options.d.ts
1156
- declare function normalizeRouterOptions(input: RouterOptionsInput): Partial<RouterOptions>;
1157
- //#endregion
1158
- export { RouterPathNode as $, RoutupError as $t, sendFile as A, Handler as At, EventStreamOptions as B, Path as Bt, sendRedirect as C, fromNodeHandler as Ct, SendFileDisposition as D, defineCoreHandler as Dt, SendFileContentOptions as E, NodeMiddleware as Et, setResponseHeaderInline as F, HandlerBaseOptions as Ft, setResponseCacheHeaders as G, RoutupEvent as Gt, EventStreamListener as H, PathMatcherOptions as Ht, appendResponseHeader as I, HandlerSymbol as It, Router as J, NextFn as Jt, isError as K, RoutupEventCreateContext as Kt, appendResponseHeaderDirective as L, HandlerType as Lt, sendAccepted as M, defineErrorHandler as Mt, setResponseHeaderContentType as N, ErrorHandler as Nt, SendFileOptions as O, CoreHandler as Ot, setResponseHeaderAttachment as P, ErrorHandlerOptions as Pt, RouterOptionsInput as Q, HTTPErrorInput$1 as Qt, serializeEventStreamMessage as R, isPath as Rt, sendStream as S, WebHandlerProvider as St, SendFileContent as T, NodeHandler as Tt, EventStreamMessage as U, IDispatcher as Ut, createEventStream as V, PathMatcherExecResult as Vt, ResponseCacheHeadersOptions as W, IDispatcherEvent as Wt, IRouter as X, RoutupResponse as Xt, DispatcherEvent as Y, RoutupRequest as Yt, RouterOptions as Z, ErrorSymbol as Zt, getRequestAcceptableContentTypes as _, isHandlerOptions as _t, RequestIpOptions as a, Plugin as at, toResponse as b, fromWebHandler as bt, getRequestHostName as c, PluginNotInstalledError as ct, getRequestAcceptableLanguages as d, isPluginError as dt, HeaderName as en, RouterPipelineContext as et, getRequestAcceptableEncoding as f, PluginError as ft, getRequestAcceptableContentType as g, isHandler as gt, getRequestAcceptableCharsets as h, matchHandlerMethod as ht, useRequestNegotiator as i, isPlugin as it, sendCreated as j, HandlerOptions as jt, SendFileStats as k, CoreHandlerOptions as kt, matchRequestContentType as l, PluginInstallError as lt, getRequestAcceptableCharset as m, buildHandlerPathMatcher as mt, RequestProtocolOptions as n, StackHandlerEntry as nt, getRequestIP as o, PluginInstallContext as ot, getRequestAcceptableEncodings as p, PluginErrorCode as pt, createError as q, IRoutupEvent as qt, getRequestProtocol as r, StackRouterEntry as rt, RequestHostNameOptions as s, PluginInstallFn as st, normalizeRouterOptions as t, MethodName as tn, StackEntry as tt, getRequestAcceptableLanguage as u, PluginAlreadyInstalledError as ut, getRequestHeader as v, isWebHandler as vt, sendFormat as w, fromNodeMiddleware as wt, setResponseContentTypeByFileName as x, WebHandler as xt, isRequestCacheable as y, isWebHandlerProvider as yt, EventStreamHandle as z, PathMatcher as zt };
1159
- //# sourceMappingURL=index-DdsCL8RI.d.mts.map