routup 5.0.0-beta.2 → 5.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bun.d.mts +2 -2
- package/dist/bun.mjs +2 -2
- package/dist/cloudflare.d.mts +2 -2
- package/dist/cloudflare.mjs +2 -2
- package/dist/deno.d.mts +2 -2
- package/dist/deno.mjs +2 -2
- package/dist/generic.d.mts +2 -2
- package/dist/generic.mjs +2 -2
- package/dist/{index-BBvBVzPm.d.mts → index-doDmTYzg.d.mts} +385 -246
- package/dist/node.d.mts +2 -2
- package/dist/node.mjs +2 -2
- package/dist/service-worker.d.mts +2 -2
- package/dist/service-worker.mjs +2 -2
- package/dist/{src-CNoRH9eg.mjs → src-Ck8GklBr.mjs} +864 -719
- package/dist/src-Ck8GklBr.mjs.map +1 -0
- package/package.json +12 -17
- package/dist/bun.cjs +0 -69
- package/dist/bun.cjs.map +0 -1
- package/dist/bun.d.cts +0 -8
- package/dist/cloudflare.cjs +0 -69
- package/dist/cloudflare.cjs.map +0 -1
- package/dist/cloudflare.d.cts +0 -8
- package/dist/deno.cjs +0 -69
- package/dist/deno.cjs.map +0 -1
- package/dist/deno.d.cts +0 -8
- package/dist/generic.cjs +0 -69
- package/dist/generic.cjs.map +0 -1
- package/dist/generic.d.cts +0 -8
- package/dist/index-eUBZJk6a.d.cts +0 -848
- package/dist/node.cjs +0 -73
- package/dist/node.cjs.map +0 -1
- package/dist/node.d.cts +0 -11
- package/dist/service-worker.cjs +0 -69
- package/dist/service-worker.cjs.map +0 -1
- package/dist/service-worker.d.cts +0 -10
- package/dist/src-BTv-fDqY.cjs +0 -1974
- package/dist/src-BTv-fDqY.cjs.map +0 -1
- package/dist/src-CNoRH9eg.mjs.map +0 -1
|
@@ -1,848 +0,0 @@
|
|
|
1
|
-
import { FastURL, ServerRequest } from "srvx";
|
|
2
|
-
import { HTTPError, HTTPErrorInput, HTTPErrorInput as HTTPErrorInput$1 } from "@ebec/http";
|
|
3
|
-
import { Key, ParseOptions, PathToRegexpOptions } from "path-to-regexp";
|
|
4
|
-
import { IncomingMessage, ServerResponse } from "node:http";
|
|
5
|
-
import Negotiator from "negotiator";
|
|
6
|
-
|
|
7
|
-
//#region src/constants.d.ts
|
|
8
|
-
declare enum MethodName {
|
|
9
|
-
GET = "GET",
|
|
10
|
-
POST = "POST",
|
|
11
|
-
PUT = "PUT",
|
|
12
|
-
PATCH = "PATCH",
|
|
13
|
-
DELETE = "DELETE",
|
|
14
|
-
OPTIONS = "OPTIONS",
|
|
15
|
-
HEAD = "HEAD"
|
|
16
|
-
}
|
|
17
|
-
declare enum HeaderName {
|
|
18
|
-
ACCEPT = "accept",
|
|
19
|
-
ACCEPT_CHARSET = "accept-charset",
|
|
20
|
-
ACCEPT_ENCODING = "accept-encoding",
|
|
21
|
-
ACCEPT_LANGUAGE = "accept-language",
|
|
22
|
-
ACCEPT_RANGES = "accept-ranges",
|
|
23
|
-
ALLOW = "allow",
|
|
24
|
-
CACHE_CONTROL = "cache-control",
|
|
25
|
-
CONTENT_DISPOSITION = "content-disposition",
|
|
26
|
-
CONTENT_ENCODING = "content-encoding",
|
|
27
|
-
CONTENT_LENGTH = "content-length",
|
|
28
|
-
CONTENT_RANGE = "content-range",
|
|
29
|
-
CONTENT_TYPE = "content-type",
|
|
30
|
-
CONNECTION = "connection",
|
|
31
|
-
COOKIE = "cookie",
|
|
32
|
-
ETag = "etag",
|
|
33
|
-
HOST = "host",
|
|
34
|
-
IF_MODIFIED_SINCE = "if-modified-since",
|
|
35
|
-
IF_NONE_MATCH = "if-none-match",
|
|
36
|
-
LAST_MODIFIED = "last-modified",
|
|
37
|
-
LOCATION = "location",
|
|
38
|
-
RANGE = "range",
|
|
39
|
-
RATE_LIMIT_LIMIT = "ratelimit-limit",
|
|
40
|
-
RATE_LIMIT_REMAINING = "ratelimit-remaining",
|
|
41
|
-
RATE_LIMIT_RESET = "ratelimit-reset",
|
|
42
|
-
RETRY_AFTER = "retry-after",
|
|
43
|
-
SET_COOKIE = "set-cookie",
|
|
44
|
-
TRANSFER_ENCODING = "transfer-encoding",
|
|
45
|
-
X_ACCEL_BUFFERING = "x-accel-buffering",
|
|
46
|
-
X_FORWARDED_HOST = "x-forwarded-host",
|
|
47
|
-
X_FORWARDED_FOR = "x-forwarded-for",
|
|
48
|
-
X_FORWARDED_PROTO = "x-forwarded-proto"
|
|
49
|
-
}
|
|
50
|
-
//#endregion
|
|
51
|
-
//#region src/error/module.d.ts
|
|
52
|
-
declare class RoutupError extends HTTPError {
|
|
53
|
-
constructor(input?: HTTPErrorInput$1);
|
|
54
|
-
}
|
|
55
|
-
//#endregion
|
|
56
|
-
//#region src/event/types.d.ts
|
|
57
|
-
type RoutupResponse = {
|
|
58
|
-
status: number;
|
|
59
|
-
headers: Headers;
|
|
60
|
-
statusText?: string;
|
|
61
|
-
};
|
|
62
|
-
type RoutupRequest = ServerRequest;
|
|
63
|
-
interface IRoutupEvent {
|
|
64
|
-
/**
|
|
65
|
-
* The srvx ServerRequest (extends Web Standard Request).
|
|
66
|
-
*/
|
|
67
|
-
readonly request: RoutupRequest;
|
|
68
|
-
/**
|
|
69
|
-
* Route parameters extracted from the URL path pattern.
|
|
70
|
-
*/
|
|
71
|
-
params: Record<string, any>;
|
|
72
|
-
/**
|
|
73
|
-
* Current request path, adjusted relative to the mount point during router nesting.
|
|
74
|
-
*/
|
|
75
|
-
path: string;
|
|
76
|
-
/**
|
|
77
|
-
* HTTP method (GET, POST, PUT, etc.).
|
|
78
|
-
*/
|
|
79
|
-
readonly method: string;
|
|
80
|
-
/**
|
|
81
|
-
* Accumulated mount path from nested routers.
|
|
82
|
-
*/
|
|
83
|
-
mountPath: string;
|
|
84
|
-
/**
|
|
85
|
-
* Error that occurred during dispatch, if any.
|
|
86
|
-
*/
|
|
87
|
-
error?: RoutupError;
|
|
88
|
-
/**
|
|
89
|
-
* Router ID stack for nesting tracking.
|
|
90
|
-
* Used internally by router options resolution.
|
|
91
|
-
*/
|
|
92
|
-
routerPath: number[];
|
|
93
|
-
/**
|
|
94
|
-
* Web Standard Headers from the request.
|
|
95
|
-
*/
|
|
96
|
-
readonly headers: Headers;
|
|
97
|
-
/**
|
|
98
|
-
* Lazily-parsed URL search parameters.
|
|
99
|
-
*
|
|
100
|
-
* For advanced query parsing (arrays, nesting), use `@routup/query`.
|
|
101
|
-
*/
|
|
102
|
-
readonly searchParams: URLSearchParams;
|
|
103
|
-
/**
|
|
104
|
-
* Response accumulator — set status/headers before returning a plain value.
|
|
105
|
-
*
|
|
106
|
-
* If the handler returns a `Response` object directly, these values are
|
|
107
|
-
* ignored. They only apply when returning plain values (string, object, etc.)
|
|
108
|
-
* that go through `toResponse()`.
|
|
109
|
-
*/
|
|
110
|
-
readonly response: RoutupResponse;
|
|
111
|
-
/**
|
|
112
|
-
* Whether a response has been produced.
|
|
113
|
-
*/
|
|
114
|
-
dispatched: boolean;
|
|
115
|
-
/**
|
|
116
|
-
* Per-request store for caching and plugin state.
|
|
117
|
-
*
|
|
118
|
-
* Use symbol keys (e.g., `Symbol.for('routup:body')`) to avoid collisions.
|
|
119
|
-
* Data is garbage collected with the event when the request completes.
|
|
120
|
-
*/
|
|
121
|
-
readonly store: Record<string | symbol, unknown>;
|
|
122
|
-
/**
|
|
123
|
-
* Call the next handler in the pipeline (onion model).
|
|
124
|
-
*
|
|
125
|
-
* The result is cached — calling `next()` multiple times returns the same response.
|
|
126
|
-
* Returns the downstream `Response`, or `undefined` if no handler matched.
|
|
127
|
-
*/
|
|
128
|
-
next(): Promise<Response | undefined>;
|
|
129
|
-
}
|
|
130
|
-
//#endregion
|
|
131
|
-
//#region src/event/module.d.ts
|
|
132
|
-
declare class RoutupEvent implements IRoutupEvent {
|
|
133
|
-
readonly request: RoutupRequest;
|
|
134
|
-
params: Record<string, any>;
|
|
135
|
-
path: string;
|
|
136
|
-
readonly method: string;
|
|
137
|
-
mountPath: string;
|
|
138
|
-
error?: RoutupError;
|
|
139
|
-
routerPath: number[];
|
|
140
|
-
/**
|
|
141
|
-
* Collected allowed methods (for OPTIONS).
|
|
142
|
-
*/
|
|
143
|
-
methodsAllowed: string[];
|
|
144
|
-
readonly store: Record<string | symbol, unknown>;
|
|
145
|
-
protected _dispatched: boolean;
|
|
146
|
-
protected _response?: RoutupResponse;
|
|
147
|
-
/**
|
|
148
|
-
* Cached parsed URL (avoids double-parsing).
|
|
149
|
-
*/
|
|
150
|
-
protected _url: InstanceType<typeof FastURL>;
|
|
151
|
-
protected _searchParams?: URLSearchParams;
|
|
152
|
-
/**
|
|
153
|
-
* Continuation function for middleware onion model.
|
|
154
|
-
*/
|
|
155
|
-
_next?: () => Promise<Response | undefined>;
|
|
156
|
-
/**
|
|
157
|
-
* Whether _next has already been called (guard against double-invocation).
|
|
158
|
-
*/
|
|
159
|
-
_nextCalled: boolean;
|
|
160
|
-
/**
|
|
161
|
-
* The cached result of the next handler.
|
|
162
|
-
*/
|
|
163
|
-
_nextResult?: Promise<Response | undefined>;
|
|
164
|
-
constructor(request: RoutupRequest);
|
|
165
|
-
get headers(): Headers;
|
|
166
|
-
get searchParams(): URLSearchParams;
|
|
167
|
-
get response(): RoutupResponse;
|
|
168
|
-
get dispatched(): boolean;
|
|
169
|
-
set dispatched(value: boolean);
|
|
170
|
-
next(): Promise<Response | undefined>;
|
|
171
|
-
}
|
|
172
|
-
//#endregion
|
|
173
|
-
//#region src/dispatcher/types.d.ts
|
|
174
|
-
interface IDispatcher {
|
|
175
|
-
dispatch(event: RoutupEvent): Promise<Response | undefined>;
|
|
176
|
-
}
|
|
177
|
-
//#endregion
|
|
178
|
-
//#region src/hook/constants.d.ts
|
|
179
|
-
declare enum HookName {
|
|
180
|
-
REQUEST = "request",
|
|
181
|
-
RESPONSE = "response",
|
|
182
|
-
ERROR = "error",
|
|
183
|
-
CHILD_MATCH = "childMatch",
|
|
184
|
-
CHILD_DISPATCH_BEFORE = "childDispatchBefore",
|
|
185
|
-
CHILD_DISPATCH_AFTER = "childDispatchAfter"
|
|
186
|
-
}
|
|
187
|
-
//#endregion
|
|
188
|
-
//#region src/hook/types.d.ts
|
|
189
|
-
type HookErrorListener = (event: IRoutupEvent) => Promise<unknown> | unknown;
|
|
190
|
-
type HookDefaultListener = (event: IRoutupEvent) => Promise<unknown> | unknown;
|
|
191
|
-
type HookListener = HookErrorListener | HookDefaultListener;
|
|
192
|
-
type HookUnsubscribeFn = () => void;
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region src/hook/module.d.ts
|
|
195
|
-
declare class HookManager {
|
|
196
|
-
protected items: Record<string, HookListener[]>;
|
|
197
|
-
constructor();
|
|
198
|
-
addListener(name: `${HookName}`, fn: HookListener): HookUnsubscribeFn;
|
|
199
|
-
removeListener(name: `${HookName}`): void;
|
|
200
|
-
removeListener(name: `${HookName}`, fn: HookListener): void;
|
|
201
|
-
trigger(name: `${HookName}`, event: IRoutupEvent): Promise<void>;
|
|
202
|
-
private triggerListener;
|
|
203
|
-
private isErrorListenerHook;
|
|
204
|
-
}
|
|
205
|
-
//#endregion
|
|
206
|
-
//#region src/path/type.d.ts
|
|
207
|
-
type PathMatcherOptions = PathToRegexpOptions & ParseOptions;
|
|
208
|
-
type PathMatcherExecResult = {
|
|
209
|
-
path: string;
|
|
210
|
-
params: Record<string, any>;
|
|
211
|
-
};
|
|
212
|
-
type Path = string;
|
|
213
|
-
//#endregion
|
|
214
|
-
//#region src/path/matcher.d.ts
|
|
215
|
-
declare class PathMatcher {
|
|
216
|
-
protected path: Path;
|
|
217
|
-
protected regexp: RegExp;
|
|
218
|
-
protected regexpKeys: Key[];
|
|
219
|
-
protected regexpOptions: PathMatcherOptions;
|
|
220
|
-
constructor(path: Path, options?: PathMatcherOptions);
|
|
221
|
-
test(path: string): boolean;
|
|
222
|
-
exec(path: string): PathMatcherExecResult | undefined;
|
|
223
|
-
}
|
|
224
|
-
//#endregion
|
|
225
|
-
//#region src/path/utils.d.ts
|
|
226
|
-
declare function isPath(input: unknown): input is Path;
|
|
227
|
-
//#endregion
|
|
228
|
-
//#region src/handler/constants.d.ts
|
|
229
|
-
declare enum HandlerType {
|
|
230
|
-
CORE = "core",
|
|
231
|
-
ERROR = "error"
|
|
232
|
-
}
|
|
233
|
-
declare const HandlerSymbol: unique symbol;
|
|
234
|
-
//#endregion
|
|
235
|
-
//#region src/handler/types-base.d.ts
|
|
236
|
-
type HandlerBaseOptions = {
|
|
237
|
-
method?: Uppercase<MethodName> | Lowercase<MethodName>;
|
|
238
|
-
path?: Path;
|
|
239
|
-
onError?: HookErrorListener;
|
|
240
|
-
onBefore?: HookDefaultListener;
|
|
241
|
-
onAfter?: HookDefaultListener;
|
|
242
|
-
};
|
|
243
|
-
//#endregion
|
|
244
|
-
//#region src/handler/error/types.d.ts
|
|
245
|
-
type ErrorHandler = (error: RoutupError, event: IRoutupEvent) => unknown | Promise<unknown>;
|
|
246
|
-
type ErrorHandlerOptions = HandlerBaseOptions & {
|
|
247
|
-
type: `${HandlerType.ERROR}`;
|
|
248
|
-
fn: ErrorHandler;
|
|
249
|
-
};
|
|
250
|
-
//#endregion
|
|
251
|
-
//#region src/handler/error/define.d.ts
|
|
252
|
-
/**
|
|
253
|
-
* Create an error handler.
|
|
254
|
-
*
|
|
255
|
-
* Error handlers receive errors thrown by preceding handlers in the pipeline.
|
|
256
|
-
*
|
|
257
|
-
* @param input - Handler function `(error, event) => value` or options object `{ fn, path? }`
|
|
258
|
-
*
|
|
259
|
-
* @example
|
|
260
|
-
* ```typescript
|
|
261
|
-
* router.use(defineErrorHandler((error, event) => {
|
|
262
|
-
* return { message: error.message };
|
|
263
|
-
* }));
|
|
264
|
-
* ```
|
|
265
|
-
*/
|
|
266
|
-
declare function defineErrorHandler(input: Omit<ErrorHandlerOptions, 'type'>): Handler;
|
|
267
|
-
declare function defineErrorHandler(input: ErrorHandler): Handler;
|
|
268
|
-
//#endregion
|
|
269
|
-
//#region src/handler/types.d.ts
|
|
270
|
-
type HandlerOptions = CoreHandlerOptions | ErrorHandlerOptions;
|
|
271
|
-
//#endregion
|
|
272
|
-
//#region src/handler/module.d.ts
|
|
273
|
-
declare class Handler implements IDispatcher {
|
|
274
|
-
readonly '@instanceof': symbol;
|
|
275
|
-
protected config: HandlerOptions;
|
|
276
|
-
protected hookManager: HookManager;
|
|
277
|
-
protected pathMatcher: PathMatcher | undefined;
|
|
278
|
-
protected _method: MethodName | undefined;
|
|
279
|
-
constructor(handler: HandlerOptions);
|
|
280
|
-
get type(): "error" | "core";
|
|
281
|
-
get path(): string | undefined;
|
|
282
|
-
get method(): MethodName | undefined;
|
|
283
|
-
dispatch(event: RoutupEvent): Promise<Response | undefined>;
|
|
284
|
-
matchPath(path: string): boolean;
|
|
285
|
-
setPath(path?: Path): void;
|
|
286
|
-
matchMethod(method: `${MethodName}`): boolean;
|
|
287
|
-
setMethod(input?: `${MethodName}`): void;
|
|
288
|
-
protected mountHooks(): void;
|
|
289
|
-
}
|
|
290
|
-
//#endregion
|
|
291
|
-
//#region src/handler/core/types.d.ts
|
|
292
|
-
type CoreHandler = (event: IRoutupEvent) => unknown | Promise<unknown>;
|
|
293
|
-
type CoreHandlerOptions = HandlerBaseOptions & {
|
|
294
|
-
type: `${HandlerType.CORE}`;
|
|
295
|
-
fn: CoreHandler;
|
|
296
|
-
};
|
|
297
|
-
//#endregion
|
|
298
|
-
//#region src/handler/core/define.d.ts
|
|
299
|
-
/**
|
|
300
|
-
* Create a request handler.
|
|
301
|
-
*
|
|
302
|
-
* @param input - Handler function `(event) => value` or options object `{ fn, path?, method? }`
|
|
303
|
-
*
|
|
304
|
-
* @example
|
|
305
|
-
* ```typescript
|
|
306
|
-
* // Shorthand — function only
|
|
307
|
-
* router.get('/', defineCoreHandler((event) => 'Hello'));
|
|
308
|
-
*
|
|
309
|
-
* // Verbose — with path and method
|
|
310
|
-
* router.use(defineCoreHandler({
|
|
311
|
-
* path: '/users/:id',
|
|
312
|
-
* method: 'GET',
|
|
313
|
-
* fn: (event) => ({ id: event.params.id }),
|
|
314
|
-
* }));
|
|
315
|
-
* ```
|
|
316
|
-
*/
|
|
317
|
-
declare function defineCoreHandler(input: Omit<CoreHandlerOptions, 'type'>): Handler;
|
|
318
|
-
declare function defineCoreHandler(input: CoreHandler): Handler;
|
|
319
|
-
//#endregion
|
|
320
|
-
//#region src/handler/adapters/node/types.d.ts
|
|
321
|
-
type NodeHandler = (req: IncomingMessage, res: ServerResponse) => unknown | Promise<unknown>;
|
|
322
|
-
type NodeMiddleware = (req: IncomingMessage, res: ServerResponse, next: (err?: unknown) => void) => unknown | Promise<unknown>;
|
|
323
|
-
//#endregion
|
|
324
|
-
//#region src/handler/adapters/node/define.d.ts
|
|
325
|
-
/**
|
|
326
|
-
* Wraps a Node.js `(req, res)` handler for use in the routup pipeline.
|
|
327
|
-
*
|
|
328
|
-
* @example
|
|
329
|
-
* ```typescript
|
|
330
|
-
* import { fromNodeHandler } from 'routup/node';
|
|
331
|
-
*
|
|
332
|
-
* router.use(fromNodeHandler((req, res) => {
|
|
333
|
-
* res.end('Hello');
|
|
334
|
-
* }));
|
|
335
|
-
* ```
|
|
336
|
-
*/
|
|
337
|
-
declare function fromNodeHandler(handler: NodeHandler): Handler;
|
|
338
|
-
/**
|
|
339
|
-
* Wraps a Node.js `(req, res, next)` middleware for use in the routup pipeline.
|
|
340
|
-
*
|
|
341
|
-
* @example
|
|
342
|
-
* ```typescript
|
|
343
|
-
* import cors from 'cors';
|
|
344
|
-
* import { fromNodeMiddleware } from 'routup/node';
|
|
345
|
-
*
|
|
346
|
-
* router.use(fromNodeMiddleware(cors()));
|
|
347
|
-
* ```
|
|
348
|
-
*/
|
|
349
|
-
declare function fromNodeMiddleware(handler: NodeMiddleware): Handler;
|
|
350
|
-
//#endregion
|
|
351
|
-
//#region src/handler/adapters/web/types.d.ts
|
|
352
|
-
/**
|
|
353
|
-
* A plain function that follows the Web Fetch API signature.
|
|
354
|
-
* Compatible with any framework that exposes a fetch-style entry point.
|
|
355
|
-
*/
|
|
356
|
-
interface WebHandler {
|
|
357
|
-
(request: Request): Response | Promise<Response>;
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* An object with a `fetch` method (e.g. another router, Hono app, etc.).
|
|
361
|
-
*/
|
|
362
|
-
interface WebHandlerProvider {
|
|
363
|
-
fetch(request: Request): Response | Promise<Response>;
|
|
364
|
-
}
|
|
365
|
-
//#endregion
|
|
366
|
-
//#region src/handler/adapters/web/define.d.ts
|
|
367
|
-
/**
|
|
368
|
-
* Create a handler from a Web Fetch API-compatible function or object.
|
|
369
|
-
*
|
|
370
|
-
* Wraps an external app (e.g. Hono, another Router) so it can be mounted
|
|
371
|
-
* via `router.use()`. The original request is passed through as-is.
|
|
372
|
-
*
|
|
373
|
-
* @param input - Fetch function `(request) => Response` or object with a `fetch` method
|
|
374
|
-
*
|
|
375
|
-
* @experimental
|
|
376
|
-
*
|
|
377
|
-
* @example
|
|
378
|
-
* ```ts
|
|
379
|
-
* // Mount an object with a fetch method
|
|
380
|
-
* router.use('/api', fromWebHandler(honoApp));
|
|
381
|
-
*
|
|
382
|
-
* // Mount a plain fetch function
|
|
383
|
-
* router.use('/proxy', fromWebHandler((req) => fetch(req)));
|
|
384
|
-
* ```
|
|
385
|
-
*/
|
|
386
|
-
declare function fromWebHandler(input: WebHandler): Handler;
|
|
387
|
-
declare function fromWebHandler(input: WebHandlerProvider): Handler;
|
|
388
|
-
//#endregion
|
|
389
|
-
//#region src/handler/adapters/web/is.d.ts
|
|
390
|
-
declare function isWebHandlerProvider(input: unknown): input is WebHandlerProvider;
|
|
391
|
-
declare function isWebHandler(input: unknown): input is WebHandler;
|
|
392
|
-
//#endregion
|
|
393
|
-
//#region src/handler/is.d.ts
|
|
394
|
-
declare function isHandlerOptions(input: unknown): input is HandlerOptions;
|
|
395
|
-
declare function isHandler(input: unknown): input is Handler;
|
|
396
|
-
//#endregion
|
|
397
|
-
//#region src/router/constants.d.ts
|
|
398
|
-
declare enum RouterPipelineStep {
|
|
399
|
-
START = 0,
|
|
400
|
-
LOOKUP = 1,
|
|
401
|
-
CHILD_BEFORE = 2,
|
|
402
|
-
CHILD_DISPATCH = 3,
|
|
403
|
-
CHILD_AFTER = 4,
|
|
404
|
-
FINISH = 5
|
|
405
|
-
}
|
|
406
|
-
//#endregion
|
|
407
|
-
//#region src/router/types.d.ts
|
|
408
|
-
type RouterPipelineContext = {
|
|
409
|
-
step: RouterPipelineStep;
|
|
410
|
-
event: RoutupEvent;
|
|
411
|
-
stackIndex: number;
|
|
412
|
-
response?: Response;
|
|
413
|
-
};
|
|
414
|
-
interface IRouter extends IDispatcher {
|
|
415
|
-
/**
|
|
416
|
-
* Unique identifier for this router instance.
|
|
417
|
-
*/
|
|
418
|
-
readonly id: number;
|
|
419
|
-
/**
|
|
420
|
-
* Optional label for the router instance.
|
|
421
|
-
*/
|
|
422
|
-
readonly name?: string;
|
|
423
|
-
/**
|
|
424
|
-
* Public entry point — processes a request through the pipeline
|
|
425
|
-
* and returns a Response (with 404/500 fallbacks).
|
|
426
|
-
*/
|
|
427
|
-
fetch(request: RoutupRequest): Promise<Response>;
|
|
428
|
-
/**
|
|
429
|
-
* Test if a path matches this router's mount path.
|
|
430
|
-
*/
|
|
431
|
-
matchPath(path: string): boolean;
|
|
432
|
-
/**
|
|
433
|
-
* Set or clear the router's mount path.
|
|
434
|
-
*/
|
|
435
|
-
setPath(value?: Path): void;
|
|
436
|
-
/**
|
|
437
|
-
* Register a handler, router, or plugin.
|
|
438
|
-
* When a path is provided, the item is mounted at that path.
|
|
439
|
-
*/
|
|
440
|
-
use(router: IRouter): this;
|
|
441
|
-
use(handler: Handler | HandlerOptions): this;
|
|
442
|
-
use(plugin: Plugin): this;
|
|
443
|
-
use(path: Path, router: IRouter): this;
|
|
444
|
-
use(path: Path, handler: Handler | HandlerOptions): this;
|
|
445
|
-
use(path: Path, plugin: Plugin): this;
|
|
446
|
-
/** Register GET handler(s). */
|
|
447
|
-
get(...handlers: (Handler | HandlerOptions)[]): this;
|
|
448
|
-
get(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
|
|
449
|
-
/** Register POST handler(s). */
|
|
450
|
-
post(...handlers: (Handler | HandlerOptions)[]): this;
|
|
451
|
-
post(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
|
|
452
|
-
/** Register PUT handler(s). */
|
|
453
|
-
put(...handlers: (Handler | HandlerOptions)[]): this;
|
|
454
|
-
put(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
|
|
455
|
-
/** Register PATCH handler(s). */
|
|
456
|
-
patch(...handlers: (Handler | HandlerOptions)[]): this;
|
|
457
|
-
patch(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
|
|
458
|
-
/** Register DELETE handler(s). */
|
|
459
|
-
delete(...handlers: (Handler | HandlerOptions)[]): this;
|
|
460
|
-
delete(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
|
|
461
|
-
/** Register HEAD handler(s). */
|
|
462
|
-
head(...handlers: (Handler | HandlerOptions)[]): this;
|
|
463
|
-
head(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
|
|
464
|
-
/** Register OPTIONS handler(s). */
|
|
465
|
-
options(...handlers: (Handler | HandlerOptions)[]): this;
|
|
466
|
-
options(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
|
|
467
|
-
/**
|
|
468
|
-
* Add a hook listener.
|
|
469
|
-
*/
|
|
470
|
-
on(name: `${HookName.REQUEST}` | `${HookName.RESPONSE}` | `${HookName.CHILD_DISPATCH_BEFORE}` | `${HookName.CHILD_DISPATCH_AFTER}`, fn: HookDefaultListener): HookUnsubscribeFn;
|
|
471
|
-
on(name: `${HookName.CHILD_MATCH}`, fn: HookDefaultListener): HookUnsubscribeFn;
|
|
472
|
-
on(name: `${HookName.ERROR}`, fn: HookErrorListener): HookUnsubscribeFn;
|
|
473
|
-
/**
|
|
474
|
-
* Remove a specific or all hook listeners for the given hook name.
|
|
475
|
-
*/
|
|
476
|
-
off(name: `${HookName}`): this;
|
|
477
|
-
off(name: `${HookName}`, fn: HookListener): this;
|
|
478
|
-
}
|
|
479
|
-
//#endregion
|
|
480
|
-
//#region src/plugin/types.d.ts
|
|
481
|
-
type PluginInstallFn = (router: IRouter) => any;
|
|
482
|
-
type Plugin = {
|
|
483
|
-
/**
|
|
484
|
-
* The name of the plugin.
|
|
485
|
-
*/
|
|
486
|
-
name: string;
|
|
487
|
-
/**
|
|
488
|
-
* The installation function called on registration.
|
|
489
|
-
*/
|
|
490
|
-
install: PluginInstallFn;
|
|
491
|
-
};
|
|
492
|
-
type PluginInstallContext = {
|
|
493
|
-
/**
|
|
494
|
-
* The name property overwrites the name defined by the plugin.
|
|
495
|
-
*/
|
|
496
|
-
name?: string;
|
|
497
|
-
/**
|
|
498
|
-
* By specifying a path, the plugin will be installed as a child router.
|
|
499
|
-
*/
|
|
500
|
-
path?: Path;
|
|
501
|
-
};
|
|
502
|
-
//#endregion
|
|
503
|
-
//#region src/plugin/is.d.ts
|
|
504
|
-
declare function isPlugin(input: unknown): input is Plugin;
|
|
505
|
-
//#endregion
|
|
506
|
-
//#region src/utils/etag/type.d.ts
|
|
507
|
-
type EtagOptions = {
|
|
508
|
-
/**
|
|
509
|
-
* Create a weak ETag?
|
|
510
|
-
* Output is prefixed with: /W
|
|
511
|
-
*/
|
|
512
|
-
weak?: boolean;
|
|
513
|
-
/**
|
|
514
|
-
* Threshold of bytes from which an etag is generated.
|
|
515
|
-
*
|
|
516
|
-
* default: undefined
|
|
517
|
-
*/
|
|
518
|
-
threshold?: number;
|
|
519
|
-
};
|
|
520
|
-
type EtagFn = (body: any, encoding?: BufferEncoding, size?: number) => Promise<string | undefined>;
|
|
521
|
-
type EtagInput = boolean | EtagOptions | EtagFn;
|
|
522
|
-
//#endregion
|
|
523
|
-
//#region src/utils/trust-proxy/type.d.ts
|
|
524
|
-
type TrustProxyFn = (address: string, hop: number) => boolean;
|
|
525
|
-
type TrustProxyInput = boolean | number | string | string[] | TrustProxyFn;
|
|
526
|
-
//#endregion
|
|
527
|
-
//#region src/router-options/type.d.ts
|
|
528
|
-
type RouterOptions = {
|
|
529
|
-
/**
|
|
530
|
-
* The path the router is mounted on.
|
|
531
|
-
*
|
|
532
|
-
* @type string
|
|
533
|
-
* @default '/'
|
|
534
|
-
*/
|
|
535
|
-
path?: Path;
|
|
536
|
-
/**
|
|
537
|
-
* Name of the router.
|
|
538
|
-
*/
|
|
539
|
-
name?: string;
|
|
540
|
-
/**
|
|
541
|
-
* default: 2
|
|
542
|
-
*/
|
|
543
|
-
subdomainOffset: number;
|
|
544
|
-
/**
|
|
545
|
-
* default: 0
|
|
546
|
-
*/
|
|
547
|
-
proxyIpMax: number;
|
|
548
|
-
/**
|
|
549
|
-
* default: () => true
|
|
550
|
-
*/
|
|
551
|
-
etag: EtagFn;
|
|
552
|
-
/**
|
|
553
|
-
* default: () => false
|
|
554
|
-
*/
|
|
555
|
-
trustProxy: TrustProxyFn;
|
|
556
|
-
};
|
|
557
|
-
type RouterOptionsInput = Omit<Partial<RouterOptions>, 'etag' | 'trustProxy'> & {
|
|
558
|
-
/**
|
|
559
|
-
* default: true
|
|
560
|
-
*/
|
|
561
|
-
etag?: EtagInput;
|
|
562
|
-
/**
|
|
563
|
-
* default: false
|
|
564
|
-
*/
|
|
565
|
-
trustProxy?: TrustProxyInput;
|
|
566
|
-
};
|
|
567
|
-
//#endregion
|
|
568
|
-
//#region src/router/module.d.ts
|
|
569
|
-
declare class Router implements IRouter {
|
|
570
|
-
readonly '@instanceof': symbol;
|
|
571
|
-
/**
|
|
572
|
-
* An identifier for the router instance.
|
|
573
|
-
*/
|
|
574
|
-
readonly id: number;
|
|
575
|
-
/**
|
|
576
|
-
* A label for the router instance.
|
|
577
|
-
*/
|
|
578
|
-
readonly name?: string;
|
|
579
|
-
/**
|
|
580
|
-
* Array of mounted layers, routes & routers.
|
|
581
|
-
*
|
|
582
|
-
* @protected
|
|
583
|
-
*/
|
|
584
|
-
protected stack: (Router | Handler)[];
|
|
585
|
-
/**
|
|
586
|
-
* Path matcher for the current mount path.
|
|
587
|
-
*
|
|
588
|
-
* @protected
|
|
589
|
-
*/
|
|
590
|
-
protected pathMatcher: PathMatcher | undefined;
|
|
591
|
-
/**
|
|
592
|
-
* A hook manager.
|
|
593
|
-
*
|
|
594
|
-
* @protected
|
|
595
|
-
*/
|
|
596
|
-
protected hookManager: HookManager;
|
|
597
|
-
constructor(options?: RouterOptionsInput);
|
|
598
|
-
matchPath(path: string): boolean;
|
|
599
|
-
setPath(value?: Path): void;
|
|
600
|
-
/**
|
|
601
|
-
* Public entry point — creates a RoutupEvent from the request,
|
|
602
|
-
* runs the pipeline, and returns a Response (with 404/500 fallbacks).
|
|
603
|
-
*/
|
|
604
|
-
fetch(request: RoutupRequest): Promise<Response>;
|
|
605
|
-
protected buildFallbackResponse(request: RoutupRequest, event: RoutupEvent, status: number, message: string): Response;
|
|
606
|
-
protected executePipelineStep(context: RouterPipelineContext): Promise<void>;
|
|
607
|
-
protected executePipelineStepStart(context: RouterPipelineContext): Promise<void>;
|
|
608
|
-
protected executePipelineStepLookup(context: RouterPipelineContext): Promise<void>;
|
|
609
|
-
protected executePipelineStepChildBefore(context: RouterPipelineContext): Promise<void>;
|
|
610
|
-
protected executePipelineStepChildAfter(context: RouterPipelineContext): Promise<void>;
|
|
611
|
-
protected executePipelineStepChildDispatch(context: RouterPipelineContext): Promise<void>;
|
|
612
|
-
protected executePipelineStepFinish(context: RouterPipelineContext): Promise<void>;
|
|
613
|
-
dispatch(event: RoutupEvent): Promise<Response | undefined>;
|
|
614
|
-
delete(...handlers: (Handler | HandlerOptions)[]): this;
|
|
615
|
-
delete(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
|
|
616
|
-
get(...handlers: (Handler | HandlerOptions)[]): this;
|
|
617
|
-
get(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
|
|
618
|
-
post(...handlers: (Handler | HandlerOptions)[]): this;
|
|
619
|
-
post(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
|
|
620
|
-
put(...handlers: (Handler | HandlerOptions)[]): this;
|
|
621
|
-
put(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
|
|
622
|
-
patch(...handlers: (Handler | HandlerOptions)[]): this;
|
|
623
|
-
patch(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
|
|
624
|
-
head(...handlers: (Handler | HandlerOptions)[]): this;
|
|
625
|
-
head(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
|
|
626
|
-
options(...handlers: (Handler | HandlerOptions)[]): this;
|
|
627
|
-
options(path: Path, ...handlers: (Handler | HandlerOptions)[]): this;
|
|
628
|
-
protected useForMethod(method: MethodName, ...input: (Path | Handler | HandlerOptions)[]): void;
|
|
629
|
-
use(router: Router): this;
|
|
630
|
-
use(handler: Handler | HandlerOptions): this;
|
|
631
|
-
use(plugin: Plugin): this;
|
|
632
|
-
use(path: Path, router: Router): this;
|
|
633
|
-
use(path: Path, handler: Handler | HandlerOptions): this;
|
|
634
|
-
use(path: Path, plugin: Plugin): this;
|
|
635
|
-
protected install(plugin: Plugin, context?: PluginInstallContext): this;
|
|
636
|
-
/**
|
|
637
|
-
* Add a hook listener.
|
|
638
|
-
*
|
|
639
|
-
* @param name
|
|
640
|
-
* @param fn
|
|
641
|
-
*/
|
|
642
|
-
on(name: `${HookName.REQUEST}` | `${HookName.RESPONSE}` | `${HookName.CHILD_DISPATCH_BEFORE}` | `${HookName.CHILD_DISPATCH_AFTER}`, fn: HookDefaultListener): HookUnsubscribeFn;
|
|
643
|
-
on(name: `${HookName.CHILD_MATCH}`, fn: HookDefaultListener): HookUnsubscribeFn;
|
|
644
|
-
on(name: `${HookName.ERROR}`, fn: HookErrorListener): HookUnsubscribeFn;
|
|
645
|
-
/**
|
|
646
|
-
* Remove single or all hook listeners.
|
|
647
|
-
*
|
|
648
|
-
* @param name
|
|
649
|
-
*/
|
|
650
|
-
off(name: `${HookName}`): this;
|
|
651
|
-
off(name: `${HookName}`, fn: HookListener): this;
|
|
652
|
-
}
|
|
653
|
-
//#endregion
|
|
654
|
-
//#region src/error/create.d.ts
|
|
655
|
-
/**
|
|
656
|
-
* Create an internal error object by
|
|
657
|
-
* - an existing RoutupError (returned as-is)
|
|
658
|
-
* - an HTTPError (wrapped into a RoutupError preserving status)
|
|
659
|
-
* - an Error (wrapped preserving message and cause)
|
|
660
|
-
* - an options object (statusCode, statusMessage, etc.)
|
|
661
|
-
* - a message string
|
|
662
|
-
*
|
|
663
|
-
* @param input
|
|
664
|
-
*/
|
|
665
|
-
declare function createError(input: HTTPErrorInput | unknown): RoutupError;
|
|
666
|
-
//#endregion
|
|
667
|
-
//#region src/error/is.d.ts
|
|
668
|
-
declare function isError(input: unknown): input is RoutupError;
|
|
669
|
-
//#endregion
|
|
670
|
-
//#region src/response/helpers/cache.d.ts
|
|
671
|
-
type ResponseCacheHeadersOptions = {
|
|
672
|
-
maxAge?: number;
|
|
673
|
-
modifiedTime?: string | Date;
|
|
674
|
-
cacheControls?: string[];
|
|
675
|
-
};
|
|
676
|
-
declare function setResponseCacheHeaders(event: IRoutupEvent, options?: ResponseCacheHeadersOptions): void;
|
|
677
|
-
//#endregion
|
|
678
|
-
//#region src/response/helpers/event-stream/types.d.ts
|
|
679
|
-
/**
|
|
680
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format
|
|
681
|
-
*/
|
|
682
|
-
type EventStreamMessage = {
|
|
683
|
-
/**
|
|
684
|
-
* The event ID to set the EventSource object's last event ID value.
|
|
685
|
-
*/
|
|
686
|
-
id?: string;
|
|
687
|
-
/**
|
|
688
|
-
* The reconnection time.
|
|
689
|
-
* If the connection to the server is lost, the browser will wait for the specified time before attempting to reconnect.
|
|
690
|
-
* This must be an integer, specifying the reconnection time in milliseconds.
|
|
691
|
-
*/
|
|
692
|
-
retry?: number;
|
|
693
|
-
/**
|
|
694
|
-
* The data field for the message.
|
|
695
|
-
*/
|
|
696
|
-
data: string;
|
|
697
|
-
/**
|
|
698
|
-
* A string identifying the type of event described.
|
|
699
|
-
*/
|
|
700
|
-
event?: string;
|
|
701
|
-
};
|
|
702
|
-
type EventStreamListener<T = any> = (err: Error | null, data: T) => void | Promise<void>;
|
|
703
|
-
//#endregion
|
|
704
|
-
//#region src/response/helpers/event-stream/module.d.ts
|
|
705
|
-
type EventStreamOptions = {
|
|
706
|
-
maxMessageSize?: number;
|
|
707
|
-
};
|
|
708
|
-
type EventStreamHandle = {
|
|
709
|
-
write(message: string | EventStreamMessage): void;
|
|
710
|
-
end(): void;
|
|
711
|
-
response: Response;
|
|
712
|
-
};
|
|
713
|
-
declare function createEventStream(event: IRoutupEvent, options?: EventStreamOptions): EventStreamHandle;
|
|
714
|
-
//#endregion
|
|
715
|
-
//#region src/response/helpers/event-stream/utils.d.ts
|
|
716
|
-
declare function serializeEventStreamMessage(message: EventStreamMessage): string;
|
|
717
|
-
//#endregion
|
|
718
|
-
//#region src/response/helpers/gone.d.ts
|
|
719
|
-
declare function isResponseGone(event: IRoutupEvent): boolean;
|
|
720
|
-
declare function setResponseGone(event: IRoutupEvent): void;
|
|
721
|
-
//#endregion
|
|
722
|
-
//#region src/response/helpers/header.d.ts
|
|
723
|
-
declare function appendResponseHeader(event: IRoutupEvent, name: string, value: string | string[]): void;
|
|
724
|
-
declare function appendResponseHeaderDirective(event: IRoutupEvent, name: string, value: string | string[]): void;
|
|
725
|
-
//#endregion
|
|
726
|
-
//#region src/response/helpers/header-attachment.d.ts
|
|
727
|
-
declare function setResponseHeaderAttachment(event: IRoutupEvent, filename?: string): void;
|
|
728
|
-
//#endregion
|
|
729
|
-
//#region src/response/helpers/header-content-type.d.ts
|
|
730
|
-
declare function setResponseHeaderContentType(event: IRoutupEvent, input: string, ifNotExists?: boolean): void;
|
|
731
|
-
//#endregion
|
|
732
|
-
//#region src/response/helpers/send-accepted.d.ts
|
|
733
|
-
declare function sendAccepted(event: IRoutupEvent, data?: unknown): Promise<Response>;
|
|
734
|
-
//#endregion
|
|
735
|
-
//#region src/response/helpers/send-created.d.ts
|
|
736
|
-
declare function sendCreated(event: IRoutupEvent, data?: unknown): Promise<Response>;
|
|
737
|
-
//#endregion
|
|
738
|
-
//#region src/response/helpers/send-file.d.ts
|
|
739
|
-
type SendFileContentOptions = {
|
|
740
|
-
end?: number;
|
|
741
|
-
start?: number;
|
|
742
|
-
};
|
|
743
|
-
type SendFileStats = {
|
|
744
|
-
size?: number;
|
|
745
|
-
mtime?: Date | number | string;
|
|
746
|
-
name?: string;
|
|
747
|
-
};
|
|
748
|
-
type SendFileOptions = {
|
|
749
|
-
stats: () => Promise<SendFileStats> | SendFileStats;
|
|
750
|
-
content: (options: SendFileContentOptions) => Promise<ReadableStream | ArrayBuffer | Uint8Array> | ReadableStream | ArrayBuffer | Uint8Array;
|
|
751
|
-
attachment?: boolean;
|
|
752
|
-
name?: string;
|
|
753
|
-
};
|
|
754
|
-
declare function sendFile(event: IRoutupEvent, options: SendFileOptions): Promise<Response>;
|
|
755
|
-
//#endregion
|
|
756
|
-
//#region src/response/helpers/send-format.d.ts
|
|
757
|
-
type ResponseFormatHandler = () => Response | unknown;
|
|
758
|
-
type ResponseFormats = {
|
|
759
|
-
default: ResponseFormatHandler;
|
|
760
|
-
[key: string]: ResponseFormatHandler;
|
|
761
|
-
};
|
|
762
|
-
declare function sendFormat(event: IRoutupEvent, input: ResponseFormats): Response | unknown | undefined;
|
|
763
|
-
//#endregion
|
|
764
|
-
//#region src/response/helpers/send-redirect.d.ts
|
|
765
|
-
declare function sendRedirect(event: IRoutupEvent, location: string, statusCode?: number): Response;
|
|
766
|
-
//#endregion
|
|
767
|
-
//#region src/response/helpers/send-stream.d.ts
|
|
768
|
-
declare function sendStream(event: IRoutupEvent, stream: ReadableStream): Response;
|
|
769
|
-
//#endregion
|
|
770
|
-
//#region src/response/helpers/utils.d.ts
|
|
771
|
-
declare function setResponseContentTypeByFileName(event: IRoutupEvent, fileName: string): void;
|
|
772
|
-
//#endregion
|
|
773
|
-
//#region src/response/to-response.d.ts
|
|
774
|
-
declare function toResponse(value: unknown, event: IRoutupEvent): Promise<Response | undefined>;
|
|
775
|
-
//#endregion
|
|
776
|
-
//#region src/request/helpers/body.d.ts
|
|
777
|
-
/**
|
|
778
|
-
* Read and parse the request body.
|
|
779
|
-
*
|
|
780
|
-
* - `application/x-www-form-urlencoded` → plain object (duplicate keys become arrays)
|
|
781
|
-
* - `application/json` or other → attempts JSON parse, returns undefined on failure
|
|
782
|
-
*
|
|
783
|
-
* The result is cached on the event store — calling `readBody()` multiple
|
|
784
|
-
* times returns the same parsed result.
|
|
785
|
-
*
|
|
786
|
-
* For binary or streaming access, use `event.request.arrayBuffer()`,
|
|
787
|
-
* `event.request.blob()`, or `event.request.body` directly.
|
|
788
|
-
*
|
|
789
|
-
* @experimental
|
|
790
|
-
*/
|
|
791
|
-
declare function readBody<T = unknown>(event: IRoutupEvent): Promise<T | undefined>;
|
|
792
|
-
//#endregion
|
|
793
|
-
//#region src/request/helpers/cache.d.ts
|
|
794
|
-
declare function isRequestCacheable(event: IRoutupEvent, modifiedTime: string | Date): boolean;
|
|
795
|
-
//#endregion
|
|
796
|
-
//#region src/request/helpers/header.d.ts
|
|
797
|
-
declare function getRequestHeader(event: IRoutupEvent, name: string): string | null;
|
|
798
|
-
//#endregion
|
|
799
|
-
//#region src/request/helpers/header-accept.d.ts
|
|
800
|
-
declare function getRequestAcceptableContentTypes(event: IRoutupEvent): string[];
|
|
801
|
-
declare function getRequestAcceptableContentType(event: IRoutupEvent, input?: string | string[]): string | undefined;
|
|
802
|
-
//#endregion
|
|
803
|
-
//#region src/request/helpers/header-accept-charset.d.ts
|
|
804
|
-
declare function getRequestAcceptableCharsets(event: IRoutupEvent): string[];
|
|
805
|
-
declare function getRequestAcceptableCharset(event: IRoutupEvent, input: string | string[]): string | undefined;
|
|
806
|
-
//#endregion
|
|
807
|
-
//#region src/request/helpers/header-accept-encoding.d.ts
|
|
808
|
-
declare function getRequestAcceptableEncodings(event: IRoutupEvent): string[];
|
|
809
|
-
declare function getRequestAcceptableEncoding(event: IRoutupEvent, input: string | string[]): string | undefined;
|
|
810
|
-
//#endregion
|
|
811
|
-
//#region src/request/helpers/header-accept-language.d.ts
|
|
812
|
-
declare function getRequestAcceptableLanguages(event: IRoutupEvent): string[];
|
|
813
|
-
declare function getRequestAcceptableLanguage(event: IRoutupEvent, input?: string | string[]): string | undefined;
|
|
814
|
-
//#endregion
|
|
815
|
-
//#region src/request/helpers/header-content-type.d.ts
|
|
816
|
-
declare function matchRequestContentType(event: IRoutupEvent, contentType: string): boolean;
|
|
817
|
-
//#endregion
|
|
818
|
-
//#region src/request/helpers/hostname.d.ts
|
|
819
|
-
type RequestHostNameOptions = {
|
|
820
|
-
trustProxy?: TrustProxyInput;
|
|
821
|
-
};
|
|
822
|
-
declare function getRequestHostName(event: IRoutupEvent, options?: RequestHostNameOptions): string | undefined;
|
|
823
|
-
//#endregion
|
|
824
|
-
//#region src/request/helpers/ip.d.ts
|
|
825
|
-
type RequestIpOptions = {
|
|
826
|
-
trustProxy?: TrustProxyInput;
|
|
827
|
-
};
|
|
828
|
-
/**
|
|
829
|
-
* Get the client IP address from the request.
|
|
830
|
-
*
|
|
831
|
-
* When `trustProxy` is configured, walks the `X-Forwarded-For` chain
|
|
832
|
-
* and returns the rightmost untrusted address (the actual client IP).
|
|
833
|
-
* Falls back to `event.request.ip` (the direct connection IP).
|
|
834
|
-
*/
|
|
835
|
-
declare function getRequestIP(event: IRoutupEvent, options?: RequestIpOptions): string | undefined;
|
|
836
|
-
//#endregion
|
|
837
|
-
//#region src/request/helpers/negotiator.d.ts
|
|
838
|
-
declare function useRequestNegotiator(event: IRoutupEvent): Negotiator;
|
|
839
|
-
//#endregion
|
|
840
|
-
//#region src/request/helpers/protocol.d.ts
|
|
841
|
-
type RequestProtocolOptions = {
|
|
842
|
-
trustProxy?: TrustProxyInput;
|
|
843
|
-
default?: string;
|
|
844
|
-
};
|
|
845
|
-
declare function getRequestProtocol(event: IRoutupEvent, options?: RequestProtocolOptions): string;
|
|
846
|
-
//#endregion
|
|
847
|
-
export { RouterPipelineContext as $, sendAccepted as A, RoutupRequest as At, createEventStream as B, sendRedirect as C, PathMatcher as Ct, SendFileStats as D, IDispatcher as Dt, SendFileOptions as E, PathMatcherOptions as Et, isResponseGone as F, MethodName as Ft, isError as G, EventStreamMessage as H, setResponseGone as I, isPlugin as J, createError as K, serializeEventStreamMessage as L, setResponseHeaderAttachment as M, HTTPErrorInput$1 as Mt, appendResponseHeader as N, RoutupError as Nt, sendFile as O, RoutupEvent as Ot, appendResponseHeaderDirective as P, HeaderName as Pt, IRouter as Q, EventStreamHandle as R, sendStream as S, isPath as St, SendFileContentOptions as T, PathMatcherExecResult as Tt, ResponseCacheHeadersOptions as U, EventStreamListener as V, setResponseCacheHeaders as W, PluginInstallContext as X, Plugin as Y, PluginInstallFn as Z, getRequestHeader as _, ErrorHandler as _t, getRequestIP as a, WebHandler as at, toResponse as b, HandlerSymbol as bt, matchRequestContentType as c, fromNodeMiddleware as ct, getRequestAcceptableEncoding as d, defineCoreHandler as dt, isHandler as et, getRequestAcceptableEncodings as f, CoreHandler as ft, getRequestAcceptableContentTypes as g, defineErrorHandler as gt, getRequestAcceptableContentType as h, HandlerOptions as ht, RequestIpOptions as i, fromWebHandler as it, setResponseHeaderContentType as j, RoutupResponse as jt, sendCreated as k, IRoutupEvent as kt, getRequestAcceptableLanguage as l, NodeHandler as lt, getRequestAcceptableCharsets as m, Handler as mt, getRequestProtocol as n, isWebHandler as nt, RequestHostNameOptions as o, WebHandlerProvider as ot, getRequestAcceptableCharset as p, CoreHandlerOptions as pt, Router as q, useRequestNegotiator as r, isWebHandlerProvider as rt, getRequestHostName as s, fromNodeHandler as st, RequestProtocolOptions as t, isHandlerOptions as tt, getRequestAcceptableLanguages as u, NodeMiddleware as ut, isRequestCacheable as v, ErrorHandlerOptions as vt, sendFormat as w, Path as wt, setResponseContentTypeByFileName as x, HandlerType as xt, readBody as y, HandlerBaseOptions as yt, EventStreamOptions as z };
|
|
848
|
-
//# sourceMappingURL=index-eUBZJk6a.d.cts.map
|