routup 4.0.2 → 5.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.
Files changed (169) hide show
  1. package/README.md +87 -134
  2. package/dist/bun.cjs +66 -0
  3. package/dist/bun.cjs.map +1 -0
  4. package/dist/bun.d.cts +8 -0
  5. package/dist/bun.d.mts +8 -0
  6. package/dist/bun.mjs +13 -0
  7. package/dist/bun.mjs.map +1 -0
  8. package/dist/cloudflare.cjs +66 -0
  9. package/dist/cloudflare.cjs.map +1 -0
  10. package/dist/cloudflare.d.cts +8 -0
  11. package/dist/cloudflare.d.mts +8 -0
  12. package/dist/cloudflare.mjs +13 -0
  13. package/dist/cloudflare.mjs.map +1 -0
  14. package/dist/deno.cjs +66 -0
  15. package/dist/deno.cjs.map +1 -0
  16. package/dist/deno.d.cts +8 -0
  17. package/dist/deno.d.mts +8 -0
  18. package/dist/deno.mjs +13 -0
  19. package/dist/deno.mjs.map +1 -0
  20. package/dist/generic.cjs +66 -0
  21. package/dist/generic.cjs.map +1 -0
  22. package/dist/generic.d.cts +8 -0
  23. package/dist/generic.d.mts +8 -0
  24. package/dist/generic.mjs +13 -0
  25. package/dist/generic.mjs.map +1 -0
  26. package/dist/index-9K5FcIb3.d.cts +786 -0
  27. package/dist/index-B6F5CzQy.d.mts +786 -0
  28. package/dist/node.cjs +70 -0
  29. package/dist/node.cjs.map +1 -0
  30. package/dist/node.d.cts +11 -0
  31. package/dist/node.d.mts +11 -0
  32. package/dist/node.mjs +16 -0
  33. package/dist/node.mjs.map +1 -0
  34. package/dist/service-worker.cjs +66 -0
  35. package/dist/service-worker.cjs.map +1 -0
  36. package/dist/service-worker.d.cts +10 -0
  37. package/dist/service-worker.d.mts +10 -0
  38. package/dist/service-worker.mjs +13 -0
  39. package/dist/service-worker.mjs.map +1 -0
  40. package/dist/src-C789deGE.mjs +1599 -0
  41. package/dist/src-C789deGE.mjs.map +1 -0
  42. package/dist/src-Ca2_b8P0.cjs +1939 -0
  43. package/dist/src-Ca2_b8P0.cjs.map +1 -0
  44. package/package.json +76 -36
  45. package/dist/adapters/index.d.ts +0 -3
  46. package/dist/adapters/node/index.d.ts +0 -1
  47. package/dist/adapters/node/module.d.ts +0 -6
  48. package/dist/adapters/raw/header.d.ts +0 -3
  49. package/dist/adapters/raw/index.d.ts +0 -3
  50. package/dist/adapters/raw/module.d.ts +0 -4
  51. package/dist/adapters/raw/type.d.ts +0 -18
  52. package/dist/adapters/web/index.d.ts +0 -2
  53. package/dist/adapters/web/module.d.ts +0 -4
  54. package/dist/adapters/web/type.d.ts +0 -3
  55. package/dist/constants.d.ts +0 -42
  56. package/dist/dispatcher/event/dispatch.d.ts +0 -4
  57. package/dist/dispatcher/event/error.d.ts +0 -5
  58. package/dist/dispatcher/event/index.d.ts +0 -5
  59. package/dist/dispatcher/event/is.d.ts +0 -3
  60. package/dist/dispatcher/event/module.d.ts +0 -56
  61. package/dist/dispatcher/event/types.d.ts +0 -9
  62. package/dist/dispatcher/index.d.ts +0 -2
  63. package/dist/dispatcher/type.d.ts +0 -4
  64. package/dist/error/create.d.ts +0 -11
  65. package/dist/error/index.d.ts +0 -3
  66. package/dist/error/is.d.ts +0 -2
  67. package/dist/error/module.d.ts +0 -3
  68. package/dist/handler/constants.d.ts +0 -5
  69. package/dist/handler/core/define.d.ts +0 -4
  70. package/dist/handler/core/index.d.ts +0 -2
  71. package/dist/handler/core/types.d.ts +0 -10
  72. package/dist/handler/error/define.d.ts +0 -4
  73. package/dist/handler/error/index.d.ts +0 -2
  74. package/dist/handler/error/types.d.ts +0 -11
  75. package/dist/handler/index.d.ts +0 -7
  76. package/dist/handler/is.d.ts +0 -4
  77. package/dist/handler/module.d.ts +0 -23
  78. package/dist/handler/types-base.d.ts +0 -10
  79. package/dist/handler/types.d.ts +0 -4
  80. package/dist/hook/constants.d.ts +0 -8
  81. package/dist/hook/index.d.ts +0 -3
  82. package/dist/hook/module.d.ts +0 -19
  83. package/dist/hook/types.d.ts +0 -5
  84. package/dist/index.cjs +0 -2314
  85. package/dist/index.cjs.map +0 -1
  86. package/dist/index.d.ts +0 -11
  87. package/dist/index.mjs +0 -2235
  88. package/dist/index.mjs.map +0 -1
  89. package/dist/path/index.d.ts +0 -3
  90. package/dist/path/matcher.d.ts +0 -11
  91. package/dist/path/type.d.ts +0 -7
  92. package/dist/path/utils.d.ts +0 -2
  93. package/dist/plugin/index.d.ts +0 -2
  94. package/dist/plugin/is.d.ts +0 -2
  95. package/dist/plugin/types.d.ts +0 -23
  96. package/dist/request/helpers/cache.d.ts +0 -2
  97. package/dist/request/helpers/env.d.ts +0 -6
  98. package/dist/request/helpers/header-accept-charset.d.ts +0 -3
  99. package/dist/request/helpers/header-accept-encoding.d.ts +0 -3
  100. package/dist/request/helpers/header-accept-language.d.ts +0 -3
  101. package/dist/request/helpers/header-accept.d.ts +0 -3
  102. package/dist/request/helpers/header-content-type.d.ts +0 -2
  103. package/dist/request/helpers/header.d.ts +0 -4
  104. package/dist/request/helpers/hostname.d.ts +0 -7
  105. package/dist/request/helpers/http2.d.ts +0 -2
  106. package/dist/request/helpers/index.d.ts +0 -17
  107. package/dist/request/helpers/ip.d.ts +0 -7
  108. package/dist/request/helpers/mount-path.d.ts +0 -3
  109. package/dist/request/helpers/negotiator.d.ts +0 -3
  110. package/dist/request/helpers/params.d.ts +0 -5
  111. package/dist/request/helpers/path.d.ts +0 -2
  112. package/dist/request/helpers/protocol.d.ts +0 -8
  113. package/dist/request/helpers/router.d.ts +0 -3
  114. package/dist/request/index.d.ts +0 -3
  115. package/dist/request/module.d.ts +0 -3
  116. package/dist/request/types.d.ts +0 -12
  117. package/dist/response/helpers/cache.d.ts +0 -7
  118. package/dist/response/helpers/event-stream/factory.d.ts +0 -3
  119. package/dist/response/helpers/event-stream/index.d.ts +0 -2
  120. package/dist/response/helpers/event-stream/module.d.ts +0 -17
  121. package/dist/response/helpers/event-stream/types.d.ts +0 -24
  122. package/dist/response/helpers/event-stream/utils.d.ts +0 -2
  123. package/dist/response/helpers/gone.d.ts +0 -3
  124. package/dist/response/helpers/header-attachment.d.ts +0 -2
  125. package/dist/response/helpers/header-content-type.d.ts +0 -2
  126. package/dist/response/helpers/header.d.ts +0 -4
  127. package/dist/response/helpers/index.d.ts +0 -16
  128. package/dist/response/helpers/send-accepted.d.ts +0 -2
  129. package/dist/response/helpers/send-created.d.ts +0 -2
  130. package/dist/response/helpers/send-file.d.ts +0 -17
  131. package/dist/response/helpers/send-format.d.ts +0 -7
  132. package/dist/response/helpers/send-redirect.d.ts +0 -2
  133. package/dist/response/helpers/send-stream.d.ts +0 -3
  134. package/dist/response/helpers/send-web-blob.d.ts +0 -3
  135. package/dist/response/helpers/send-web-response.d.ts +0 -3
  136. package/dist/response/helpers/send.d.ts +0 -2
  137. package/dist/response/helpers/utils.d.ts +0 -2
  138. package/dist/response/index.d.ts +0 -3
  139. package/dist/response/module.d.ts +0 -3
  140. package/dist/response/types.d.ts +0 -3
  141. package/dist/router/constants.d.ts +0 -9
  142. package/dist/router/index.d.ts +0 -1
  143. package/dist/router/module.d.ts +0 -89
  144. package/dist/router/types.d.ts +0 -7
  145. package/dist/router/utils.d.ts +0 -3
  146. package/dist/router-options/index.d.ts +0 -2
  147. package/dist/router-options/module.d.ts +0 -4
  148. package/dist/router-options/transform.d.ts +0 -2
  149. package/dist/router-options/type.d.ts +0 -41
  150. package/dist/types.d.ts +0 -9
  151. package/dist/utils/cookie.d.ts +0 -1
  152. package/dist/utils/etag/index.d.ts +0 -3
  153. package/dist/utils/etag/module.d.ts +0 -11
  154. package/dist/utils/etag/type.d.ts +0 -15
  155. package/dist/utils/etag/utils.d.ts +0 -2
  156. package/dist/utils/index.d.ts +0 -13
  157. package/dist/utils/is-instance.d.ts +0 -1
  158. package/dist/utils/method.d.ts +0 -3
  159. package/dist/utils/mime.d.ts +0 -2
  160. package/dist/utils/next.d.ts +0 -2
  161. package/dist/utils/object.d.ts +0 -3
  162. package/dist/utils/path.d.ts +0 -5
  163. package/dist/utils/promise.d.ts +0 -1
  164. package/dist/utils/stream.d.ts +0 -6
  165. package/dist/utils/trust-proxy/index.d.ts +0 -2
  166. package/dist/utils/trust-proxy/module.d.ts +0 -2
  167. package/dist/utils/trust-proxy/type.d.ts +0 -2
  168. package/dist/utils/url.d.ts +0 -7
  169. package/dist/utils/web.d.ts +0 -3
@@ -1,17 +0,0 @@
1
- export * from './cache';
2
- export * from './env';
3
- export * from './header';
4
- export * from './header-accept';
5
- export * from './header-accept-charset';
6
- export * from './header-accept-encoding';
7
- export * from './header-accept-language';
8
- export * from './header-content-type';
9
- export * from './hostname';
10
- export * from './http2';
11
- export * from './ip';
12
- export * from './mount-path';
13
- export * from './negotiator';
14
- export * from './params';
15
- export * from './path';
16
- export * from './protocol';
17
- export * from './router';
@@ -1,7 +0,0 @@
1
- import type { TrustProxyInput } from '../../utils';
2
- import type { Request } from '../types';
3
- type RequestIpOptions = {
4
- trustProxy?: TrustProxyInput;
5
- };
6
- export declare function getRequestIP(req: Request, options?: RequestIpOptions): string;
7
- export {};
@@ -1,3 +0,0 @@
1
- import type { Request } from '../types';
2
- export declare function useRequestMountPath(req: Request): string;
3
- export declare function setRequestMountPath(req: Request, basePath: string): void;
@@ -1,3 +0,0 @@
1
- import Negotiator from 'negotiator';
2
- import type { Request } from '../types';
3
- export declare function useRequestNegotiator(req: Request): Negotiator;
@@ -1,5 +0,0 @@
1
- import type { Request } from '../types';
2
- export declare function useRequestParams(req: Request): Record<string, any>;
3
- export declare function useRequestParam(req: Request, key: string): any;
4
- export declare function setRequestParams(req: Request, data: Record<string, any>): void;
5
- export declare function setRequestParam(req: Request, key: string, value: any): void;
@@ -1,2 +0,0 @@
1
- import type { Request } from '../types';
2
- export declare function useRequestPath(req: Request): string;
@@ -1,8 +0,0 @@
1
- import type { TrustProxyInput } from '../../utils';
2
- import type { Request } from '../types';
3
- type RequestProtocolOptions = {
4
- trustProxy?: TrustProxyInput;
5
- default?: string;
6
- };
7
- export declare function getRequestProtocol(req: Request, options?: RequestProtocolOptions): string;
8
- export {};
@@ -1,3 +0,0 @@
1
- import type { Request } from '../types';
2
- export declare function setRequestRouterPath(req: Request, path: number[]): void;
3
- export declare function useRequestRouterPath(req: Request): number[] | undefined;
@@ -1,3 +0,0 @@
1
- export * from './helpers';
2
- export * from './module';
3
- export * from './types';
@@ -1,3 +0,0 @@
1
- import type { IncomingMessage } from 'node:http';
2
- import type { RequestCreateContext } from './types';
3
- export declare function createRequest(context: RequestCreateContext): IncomingMessage;
@@ -1,12 +0,0 @@
1
- import type { IncomingMessage } from 'node:http';
2
- import type { NodeReadableStream, WebReadableStream } from '../types';
3
- export type RequestBody = null | Iterable<any> | AsyncIterable<any> | NodeReadableStream | WebReadableStream;
4
- export type RequestHeaders = Record<string, string | string[]>;
5
- export type RequestCreateContext = {
6
- body?: RequestBody;
7
- headers?: RequestHeaders;
8
- method?: string;
9
- url?: string;
10
- };
11
- export interface Request extends IncomingMessage {
12
- }
@@ -1,7 +0,0 @@
1
- import type { Response } from '../types';
2
- export type ResponseCacheHeadersOptions = {
3
- maxAge?: number;
4
- modifiedTime?: string | Date;
5
- cacheControls?: string[];
6
- };
7
- export declare function setResponseCacheHeaders(res: Response, options?: ResponseCacheHeadersOptions): void;
@@ -1,3 +0,0 @@
1
- import type { Response } from '../../types';
2
- import { EventStream } from './module';
3
- export declare function createEventStream(response: Response): EventStream;
@@ -1,2 +0,0 @@
1
- export * from './factory';
2
- export * from './module';
@@ -1,17 +0,0 @@
1
- import { PassThrough } from 'readable-stream';
2
- import type { Response } from '../../types';
3
- import type { EventStreamListener, EventStreamMessage } from './types';
4
- export declare class EventStream {
5
- protected response: Response;
6
- protected passThrough: PassThrough;
7
- protected flushed: boolean;
8
- protected eventHandlers: Record<string, EventStreamListener[]>;
9
- constructor(response: Response);
10
- protected open(): void;
11
- write(message: EventStreamMessage): void;
12
- write(message: string): void;
13
- end(): void;
14
- on(event: 'close', listener: EventStreamListener): void;
15
- on(event: 'error', listener: EventStreamListener): void;
16
- protected emit(event: string, ...args: any[]): void;
17
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format
3
- */
4
- export type EventStreamMessage = {
5
- /**
6
- * The event ID to set the EventSource object's last event ID value.
7
- */
8
- id?: string;
9
- /**
10
- * The reconnection time.
11
- * If the connection to the server is lost, the browser will wait for the specified time before attempting to reconnect.
12
- * This must be an integer, specifying the reconnection time in milliseconds.
13
- */
14
- retry?: number;
15
- /**
16
- * The data field for the message.
17
- */
18
- data: string;
19
- /**
20
- * A string identifying the type of event described.
21
- */
22
- event?: string;
23
- };
24
- export type EventStreamListener<T = any> = (err: Error | null, data: T) => void | Promise<void>;
@@ -1,2 +0,0 @@
1
- import type { EventStreamMessage } from './types';
2
- export declare function serializeEventStreamMessage(message: EventStreamMessage): string;
@@ -1,3 +0,0 @@
1
- import type { Response } from '../types';
2
- export declare function isResponseGone(res: Response): any;
3
- export declare function setResponseGone(res: Response, value: boolean): void;
@@ -1,2 +0,0 @@
1
- import type { Response } from '../types';
2
- export declare function setResponseHeaderAttachment(res: Response, filename?: string): void;
@@ -1,2 +0,0 @@
1
- import type { Response } from '../types';
2
- export declare function setResponseHeaderContentType(res: Response, input: string, ifNotExists?: boolean): void;
@@ -1,4 +0,0 @@
1
- import type { OutgoingHttpHeader } from 'node:http';
2
- import type { Response } from '../types';
3
- export declare function appendResponseHeader(res: Response, name: string, value: OutgoingHttpHeader): void;
4
- export declare function appendResponseHeaderDirective(res: Response, name: string, value: OutgoingHttpHeader): void;
@@ -1,16 +0,0 @@
1
- export * from './cache';
2
- export * from './event-stream';
3
- export * from './gone';
4
- export * from './header';
5
- export * from './header-attachment';
6
- export * from './header-content-type';
7
- export * from './send';
8
- export * from './send-accepted';
9
- export * from './send-created';
10
- export * from './send-file';
11
- export * from './send-format';
12
- export * from './send-redirect';
13
- export * from './send-stream';
14
- export * from './send-web-response';
15
- export * from './send-web-blob';
16
- export * from './utils';
@@ -1,2 +0,0 @@
1
- import type { Response } from '../types';
2
- export declare function sendAccepted(res: Response, chunk?: any): Promise<void>;
@@ -1,2 +0,0 @@
1
- import type { Response } from '../types';
2
- export declare function sendCreated(res: Response, chunk?: any): Promise<void>;
@@ -1,17 +0,0 @@
1
- import type { Response } from '../types';
2
- export type SendFileContentOptions = {
3
- end?: number;
4
- start?: number;
5
- };
6
- export type SendFileStats = {
7
- size?: number;
8
- mtime?: Date | number | string;
9
- name?: string;
10
- };
11
- export type SendFileOptions = {
12
- stats: () => Promise<SendFileStats> | SendFileStats;
13
- content: (options: SendFileContentOptions) => Promise<unknown> | unknown;
14
- attachment?: boolean;
15
- name?: string;
16
- };
17
- export declare function sendFile(res: Response, options: SendFileOptions, next?: (err?: Error) => Promise<unknown> | unknown): Promise<unknown>;
@@ -1,7 +0,0 @@
1
- import type { Response } from '../types';
2
- type ResponseFormats = {
3
- default: () => void;
4
- [key: string]: () => void;
5
- };
6
- export declare function sendFormat(res: Response, input: ResponseFormats): void;
7
- export {};
@@ -1,2 +0,0 @@
1
- import type { Response } from '../types';
2
- export declare function sendRedirect(res: Response, location: string, statusCode?: number): Promise<void>;
@@ -1,3 +0,0 @@
1
- import type { NodeReadableStream, WebReadableStream } from '../../types';
2
- import type { Response } from '../types';
3
- export declare function sendStream(res: Response, stream: NodeReadableStream | WebReadableStream, next?: (err?: Error) => Promise<unknown> | unknown): Promise<unknown>;
@@ -1,3 +0,0 @@
1
- import type { WebBlob } from '../../types';
2
- import type { Response } from '../types';
3
- export declare function sendWebBlob(res: Response, blob: WebBlob): Promise<void>;
@@ -1,3 +0,0 @@
1
- import type { WebResponse } from '../../types';
2
- import type { Response } from '../types';
3
- export declare function sendWebResponse(res: Response, webResponse: WebResponse): Promise<void>;
@@ -1,2 +0,0 @@
1
- import type { Response } from '../types';
2
- export declare function send(res: Response, chunk?: any): Promise<void>;
@@ -1,2 +0,0 @@
1
- import type { Response } from '../types';
2
- export declare function setResponseContentTypeByFileName(res: Response, fileName: string): void;
@@ -1,3 +0,0 @@
1
- export * from './helpers';
2
- export * from './module';
3
- export * from './types';
@@ -1,3 +0,0 @@
1
- import type { Request } from '../request';
2
- import type { Response } from './types';
3
- export declare function createResponse(request: Request): Response;
@@ -1,3 +0,0 @@
1
- import type { ServerResponse } from 'node:http';
2
- export interface Response extends ServerResponse {
3
- }
@@ -1,9 +0,0 @@
1
- export declare const RouterSymbol: unique symbol;
2
- export declare enum RouterPipelineStep {
3
- START = 0,
4
- LOOKUP = 1,
5
- CHILD_BEFORE = 2,
6
- CHILD_DISPATCH = 3,
7
- CHILD_AFTER = 4,
8
- FINISH = 5
9
- }
@@ -1 +0,0 @@
1
- export * from './module';
@@ -1,89 +0,0 @@
1
- import { MethodName } from '../constants';
2
- import type { DispatchEvent, Dispatcher } from '../dispatcher';
3
- import type { HandlerConfig } from '../handler';
4
- import { Handler } from '../handler';
5
- import type { HookDefaultListener, HookErrorListener, HookListener, HookUnsubscribeFn } from '../hook';
6
- import { HookManager, HookName } from '../hook';
7
- import type { Path } from '../path';
8
- import { PathMatcher } from '../path';
9
- import type { Plugin, PluginInstallContext } from '../plugin';
10
- import type { RouterOptionsInput } from '../router-options';
11
- import type { RouterPipelineContext } from './types';
12
- export declare class Router implements Dispatcher {
13
- readonly '@instanceof': symbol;
14
- /**
15
- * An identifier for the router instance.
16
- */
17
- readonly id: number;
18
- /**
19
- * A label for the router instance.
20
- */
21
- readonly name?: string;
22
- /**
23
- * Array of mounted layers, routes & routers.
24
- *
25
- * @protected
26
- */
27
- protected stack: (Router | Handler)[];
28
- /**
29
- * Path matcher for the current mount path.
30
- *
31
- * @protected
32
- */
33
- protected pathMatcher: PathMatcher | undefined;
34
- /**
35
- * A hook manager.
36
- *
37
- * @protected
38
- */
39
- protected hookManager: HookManager;
40
- constructor(options?: RouterOptionsInput);
41
- matchPath(path: string): boolean;
42
- setPath(value?: Path): void;
43
- protected executePipelineStep(context: RouterPipelineContext): Promise<void>;
44
- protected executePipelineStepStart(context: RouterPipelineContext): Promise<void>;
45
- protected executePipelineStepLookup(context: RouterPipelineContext): Promise<void>;
46
- protected executePipelineStepChildBefore(context: RouterPipelineContext): Promise<void>;
47
- protected executePipelineStepChildAfter(context: RouterPipelineContext): Promise<void>;
48
- protected executePipelineStepChildDispatch(context: RouterPipelineContext): Promise<void>;
49
- protected executePipelineStepFinish(context: RouterPipelineContext): Promise<void>;
50
- dispatch(event: DispatchEvent): Promise<void>;
51
- delete(...handlers: (Handler | HandlerConfig)[]): this;
52
- delete(path: Path, ...handlers: (Handler | HandlerConfig)[]): this;
53
- get(...handlers: (Handler | HandlerConfig)[]): this;
54
- get(path: Path, ...handlers: (Handler | HandlerConfig)[]): this;
55
- post(...handlers: (Handler | HandlerConfig)[]): this;
56
- post(path: Path, ...handlers: (Handler | HandlerConfig)[]): this;
57
- put(...handlers: (Handler | HandlerConfig)[]): this;
58
- put(path: Path, ...handlers: (Handler | HandlerConfig)[]): this;
59
- patch(...handlers: (Handler | HandlerConfig)[]): this;
60
- patch(path: Path, ...handlers: (Handler | HandlerConfig)[]): this;
61
- head(...handlers: (Handler | HandlerConfig)[]): this;
62
- head(path: Path, ...handlers: (Handler | HandlerConfig)[]): this;
63
- options(...handlers: (Handler | HandlerConfig)[]): this;
64
- options(path: Path, ...handlers: (Handler | HandlerConfig)[]): this;
65
- protected useForMethod(method: MethodName, ...input: (Path | Handler | HandlerConfig)[]): void;
66
- use(router: Router): this;
67
- use(handler: Handler | HandlerConfig): this;
68
- use(plugin: Plugin): this;
69
- use(path: Path, router: Router): this;
70
- use(path: Path, handler: Handler | HandlerConfig): this;
71
- use(path: Path, plugin: Plugin): this;
72
- protected install(plugin: Plugin, context?: PluginInstallContext): this;
73
- /**
74
- * Add a hook listener.
75
- *
76
- * @param name
77
- * @param fn
78
- */
79
- on(name: `${HookName.DISPATCH_START}` | `${HookName.DISPATCH_END}` | `${HookName.CHILD_DISPATCH_BEFORE}` | `${HookName.CHILD_DISPATCH_AFTER}`, fn: HookDefaultListener): HookUnsubscribeFn;
80
- on(name: `${HookName.CHILD_MATCH}`, fn: HookErrorListener): HookUnsubscribeFn;
81
- on(name: `${HookName.ERROR}`, fn: HookErrorListener): HookUnsubscribeFn;
82
- /**
83
- * Remove single or all hook listeners.
84
- *
85
- * @param name
86
- */
87
- off(name: `${HookName}`): this;
88
- off(name: `${HookName}`, fn: HookListener): this;
89
- }
@@ -1,7 +0,0 @@
1
- import type { DispatchEvent } from '../dispatcher';
2
- import type { RouterPipelineStep } from './constants';
3
- export type RouterPipelineContext = {
4
- step: RouterPipelineStep;
5
- event: DispatchEvent;
6
- stackIndex: number;
7
- };
@@ -1,3 +0,0 @@
1
- import type { Router } from './module';
2
- export declare function generateRouterID(): number;
3
- export declare function isRouterInstance(input: unknown): input is Router;
@@ -1,2 +0,0 @@
1
- export * from './module';
2
- export * from './type';
@@ -1,4 +0,0 @@
1
- import type { RouterOptions } from './type';
2
- export declare function setRouterOptions(id: number, input: Partial<RouterOptions>): void;
3
- export declare function unsetRouterOptions(id: number): void;
4
- export declare function findRouterOption<K extends keyof RouterOptions>(key: K, path?: number[]): RouterOptions[K];
@@ -1,2 +0,0 @@
1
- import type { RouterOptions, RouterOptionsInput } from './type';
2
- export declare function transformRouterOptions(input: RouterOptionsInput): Partial<RouterOptions>;
@@ -1,41 +0,0 @@
1
- import type { Path } from '../path';
2
- import type { EtagFn, EtagInput, TrustProxyFn, TrustProxyInput } from '../utils';
3
- export type RouterOptions = {
4
- /**
5
- * The path the router is mounted on.
6
- *
7
- * @type string
8
- * @default '/'
9
- */
10
- path?: Path;
11
- /**
12
- * Name of the router.
13
- */
14
- name?: string;
15
- /**
16
- * default: 2
17
- */
18
- subdomainOffset: number;
19
- /**
20
- * default: 0
21
- */
22
- proxyIpMax: number;
23
- /**
24
- * default: () => true
25
- */
26
- etag: EtagFn;
27
- /**
28
- * default: () => false
29
- */
30
- trustProxy: TrustProxyFn;
31
- };
32
- export type RouterOptionsInput = Omit<Partial<RouterOptions>, 'etag' | 'trustProxy'> & {
33
- /**
34
- * default: true
35
- */
36
- etag?: EtagInput;
37
- /**
38
- * default: false
39
- */
40
- trustProxy?: TrustProxyInput;
41
- };
package/dist/types.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import type { Readable as NodeReadable } from 'node:stream';
2
- import type { Readable } from 'readable-stream';
3
- import type { ReadableStream } from 'stream/web';
4
- export type NodeReadableStream = NodeReadable | Readable;
5
- export type WebReadableStream = globalThis.ReadableStream | ReadableStream;
6
- export type WebResponse = globalThis.Response;
7
- export type WebRequest = globalThis.Request;
8
- export type WebBlob = globalThis.Blob;
9
- export type Next = (err?: Error) => void;
@@ -1 +0,0 @@
1
- export declare function splitCookiesString(input?: string | string[]): string[];
@@ -1,3 +0,0 @@
1
- export * from './module';
2
- export * from './utils';
3
- export * from './type';
@@ -1,11 +0,0 @@
1
- import { Buffer } from 'buffer';
2
- import { type Stats } from 'node:fs';
3
- import type { EtagOptions } from './type';
4
- /**
5
- * Generate an ETag.
6
- */
7
- export declare function generateETag(input: string | Buffer | Stats): Promise<string>;
8
- /**
9
- * Create a simple ETag.
10
- */
11
- export declare function createEtag(input: string | Buffer | Stats, options?: EtagOptions): Promise<string>;
@@ -1,15 +0,0 @@
1
- export type EtagOptions = {
2
- /**
3
- * Create a weak ETag?
4
- * Output is prefixed with: /W
5
- */
6
- weak?: boolean;
7
- /**
8
- * Threshold of bytes from which an etag is generated.
9
- *
10
- * default: undefined
11
- */
12
- threshold?: number;
13
- };
14
- export type EtagFn = (body: any, encoding?: BufferEncoding, size?: number) => Promise<string | undefined>;
15
- export type EtagInput = boolean | EtagOptions | EtagFn;
@@ -1,2 +0,0 @@
1
- import type { EtagFn, EtagOptions } from './type';
2
- export declare function buildEtagFn(input?: boolean | EtagOptions | EtagFn): EtagFn;
@@ -1,13 +0,0 @@
1
- export * from './cookie';
2
- export * from './etag';
3
- export * from './trust-proxy';
4
- export * from './is-instance';
5
- export * from './mime';
6
- export * from './method';
7
- export * from './next';
8
- export * from './object';
9
- export * from './path';
10
- export * from './promise';
11
- export * from './stream';
12
- export * from './url';
13
- export * from './web';
@@ -1 +0,0 @@
1
- export declare function isInstance(input: unknown, sym: symbol): boolean;
@@ -1,3 +0,0 @@
1
- import type { MethodName } from '../constants';
2
- export declare function toMethodName(input: string | undefined): MethodName | undefined;
3
- export declare function toMethodName(input: string | undefined, alt: MethodName): MethodName;
@@ -1,2 +0,0 @@
1
- export declare function getMimeType(type: string): string | undefined;
2
- export declare function getCharsetForMimeType(type: string): string | undefined;
@@ -1,2 +0,0 @@
1
- import type { Next } from '../types';
2
- export declare const nextPlaceholder: Next;
@@ -1,3 +0,0 @@
1
- export declare function isObject(item: unknown): item is Record<string, any>;
2
- export declare function setProperty(record: Record<PropertyKey, any>, property: PropertyKey, value: any): void;
3
- export declare function getProperty<T = any>(req: Record<PropertyKey, any>, property: PropertyKey): T;
@@ -1,5 +0,0 @@
1
- /**
2
- * Based on https://github.com/unjs/pathe v1.1.1 (055f50a6f1131f4e5c56cf259dd8816168fba329)
3
- */
4
- export declare function extname(input: string): string;
5
- export declare function basename(input: string, extension?: string): string;
@@ -1 +0,0 @@
1
- export declare function isPromise(p: unknown): p is Promise<unknown>;
@@ -1,6 +0,0 @@
1
- import type { ReadableStream as WebReadableStream } from 'stream/web';
2
- import type { Readable as NodeReadable } from 'node:stream';
3
- import type { Readable } from 'readable-stream';
4
- export declare function isNodeStream(input: unknown): input is NodeReadable | Readable;
5
- export declare function isWebStream(input: unknown): input is ReadableStream | WebReadableStream;
6
- export declare function isStream(data: any): data is NodeReadable | Readable | ReadableStream | WebReadableStream;
@@ -1,2 +0,0 @@
1
- export * from './module';
2
- export * from './type';
@@ -1,2 +0,0 @@
1
- import type { TrustProxyFn } from './type';
2
- export declare function buildTrustProxyFn(input?: boolean | number | string | string[] | TrustProxyFn): TrustProxyFn;
@@ -1,2 +0,0 @@
1
- export type TrustProxyFn = (address: string, hop: number) => boolean;
2
- export type TrustProxyInput = boolean | number | string | string[] | TrustProxyFn;
@@ -1,7 +0,0 @@
1
- export declare function hasTrailingSlash(input?: string, queryParams?: boolean): boolean;
2
- export declare function withoutTrailingSlash(input?: string, queryParams?: boolean): string;
3
- export declare function withTrailingSlash(input?: string, queryParams?: boolean): string;
4
- export declare function hasLeadingSlash(input?: string): boolean;
5
- export declare function withoutLeadingSlash(input?: string): string;
6
- export declare function withLeadingSlash(input?: string): string;
7
- export declare function cleanDoubleSlashes(input?: string): string;
@@ -1,3 +0,0 @@
1
- import type { WebBlob, WebResponse } from '../types';
2
- export declare function isWebBlob(input: unknown): input is WebBlob;
3
- export declare function isWebResponse(input: unknown): input is WebResponse;