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.
- package/README.md +87 -134
- package/dist/bun.cjs +66 -0
- package/dist/bun.cjs.map +1 -0
- package/dist/bun.d.cts +8 -0
- package/dist/bun.d.mts +8 -0
- package/dist/bun.mjs +13 -0
- package/dist/bun.mjs.map +1 -0
- package/dist/cloudflare.cjs +66 -0
- package/dist/cloudflare.cjs.map +1 -0
- package/dist/cloudflare.d.cts +8 -0
- package/dist/cloudflare.d.mts +8 -0
- package/dist/cloudflare.mjs +13 -0
- package/dist/cloudflare.mjs.map +1 -0
- package/dist/deno.cjs +66 -0
- package/dist/deno.cjs.map +1 -0
- package/dist/deno.d.cts +8 -0
- package/dist/deno.d.mts +8 -0
- package/dist/deno.mjs +13 -0
- package/dist/deno.mjs.map +1 -0
- package/dist/generic.cjs +66 -0
- package/dist/generic.cjs.map +1 -0
- package/dist/generic.d.cts +8 -0
- package/dist/generic.d.mts +8 -0
- package/dist/generic.mjs +13 -0
- package/dist/generic.mjs.map +1 -0
- package/dist/index-9K5FcIb3.d.cts +786 -0
- package/dist/index-B6F5CzQy.d.mts +786 -0
- package/dist/node.cjs +70 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +11 -0
- package/dist/node.d.mts +11 -0
- package/dist/node.mjs +16 -0
- package/dist/node.mjs.map +1 -0
- package/dist/service-worker.cjs +66 -0
- package/dist/service-worker.cjs.map +1 -0
- package/dist/service-worker.d.cts +10 -0
- package/dist/service-worker.d.mts +10 -0
- package/dist/service-worker.mjs +13 -0
- package/dist/service-worker.mjs.map +1 -0
- package/dist/src-C789deGE.mjs +1599 -0
- package/dist/src-C789deGE.mjs.map +1 -0
- package/dist/src-Ca2_b8P0.cjs +1939 -0
- package/dist/src-Ca2_b8P0.cjs.map +1 -0
- package/package.json +76 -36
- package/dist/adapters/index.d.ts +0 -3
- package/dist/adapters/node/index.d.ts +0 -1
- package/dist/adapters/node/module.d.ts +0 -6
- package/dist/adapters/raw/header.d.ts +0 -3
- package/dist/adapters/raw/index.d.ts +0 -3
- package/dist/adapters/raw/module.d.ts +0 -4
- package/dist/adapters/raw/type.d.ts +0 -18
- package/dist/adapters/web/index.d.ts +0 -2
- package/dist/adapters/web/module.d.ts +0 -4
- package/dist/adapters/web/type.d.ts +0 -3
- package/dist/constants.d.ts +0 -42
- package/dist/dispatcher/event/dispatch.d.ts +0 -4
- package/dist/dispatcher/event/error.d.ts +0 -5
- package/dist/dispatcher/event/index.d.ts +0 -5
- package/dist/dispatcher/event/is.d.ts +0 -3
- package/dist/dispatcher/event/module.d.ts +0 -56
- package/dist/dispatcher/event/types.d.ts +0 -9
- package/dist/dispatcher/index.d.ts +0 -2
- package/dist/dispatcher/type.d.ts +0 -4
- package/dist/error/create.d.ts +0 -11
- package/dist/error/index.d.ts +0 -3
- package/dist/error/is.d.ts +0 -2
- package/dist/error/module.d.ts +0 -3
- package/dist/handler/constants.d.ts +0 -5
- package/dist/handler/core/define.d.ts +0 -4
- package/dist/handler/core/index.d.ts +0 -2
- package/dist/handler/core/types.d.ts +0 -10
- package/dist/handler/error/define.d.ts +0 -4
- package/dist/handler/error/index.d.ts +0 -2
- package/dist/handler/error/types.d.ts +0 -11
- package/dist/handler/index.d.ts +0 -7
- package/dist/handler/is.d.ts +0 -4
- package/dist/handler/module.d.ts +0 -23
- package/dist/handler/types-base.d.ts +0 -10
- package/dist/handler/types.d.ts +0 -4
- package/dist/hook/constants.d.ts +0 -8
- package/dist/hook/index.d.ts +0 -3
- package/dist/hook/module.d.ts +0 -19
- package/dist/hook/types.d.ts +0 -5
- package/dist/index.cjs +0 -2314
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -11
- package/dist/index.mjs +0 -2235
- package/dist/index.mjs.map +0 -1
- package/dist/path/index.d.ts +0 -3
- package/dist/path/matcher.d.ts +0 -11
- package/dist/path/type.d.ts +0 -7
- package/dist/path/utils.d.ts +0 -2
- package/dist/plugin/index.d.ts +0 -2
- package/dist/plugin/is.d.ts +0 -2
- package/dist/plugin/types.d.ts +0 -23
- package/dist/request/helpers/cache.d.ts +0 -2
- package/dist/request/helpers/env.d.ts +0 -6
- package/dist/request/helpers/header-accept-charset.d.ts +0 -3
- package/dist/request/helpers/header-accept-encoding.d.ts +0 -3
- package/dist/request/helpers/header-accept-language.d.ts +0 -3
- package/dist/request/helpers/header-accept.d.ts +0 -3
- package/dist/request/helpers/header-content-type.d.ts +0 -2
- package/dist/request/helpers/header.d.ts +0 -4
- package/dist/request/helpers/hostname.d.ts +0 -7
- package/dist/request/helpers/http2.d.ts +0 -2
- package/dist/request/helpers/index.d.ts +0 -17
- package/dist/request/helpers/ip.d.ts +0 -7
- package/dist/request/helpers/mount-path.d.ts +0 -3
- package/dist/request/helpers/negotiator.d.ts +0 -3
- package/dist/request/helpers/params.d.ts +0 -5
- package/dist/request/helpers/path.d.ts +0 -2
- package/dist/request/helpers/protocol.d.ts +0 -8
- package/dist/request/helpers/router.d.ts +0 -3
- package/dist/request/index.d.ts +0 -3
- package/dist/request/module.d.ts +0 -3
- package/dist/request/types.d.ts +0 -12
- package/dist/response/helpers/cache.d.ts +0 -7
- package/dist/response/helpers/event-stream/factory.d.ts +0 -3
- package/dist/response/helpers/event-stream/index.d.ts +0 -2
- package/dist/response/helpers/event-stream/module.d.ts +0 -17
- package/dist/response/helpers/event-stream/types.d.ts +0 -24
- package/dist/response/helpers/event-stream/utils.d.ts +0 -2
- package/dist/response/helpers/gone.d.ts +0 -3
- package/dist/response/helpers/header-attachment.d.ts +0 -2
- package/dist/response/helpers/header-content-type.d.ts +0 -2
- package/dist/response/helpers/header.d.ts +0 -4
- package/dist/response/helpers/index.d.ts +0 -16
- package/dist/response/helpers/send-accepted.d.ts +0 -2
- package/dist/response/helpers/send-created.d.ts +0 -2
- package/dist/response/helpers/send-file.d.ts +0 -17
- package/dist/response/helpers/send-format.d.ts +0 -7
- package/dist/response/helpers/send-redirect.d.ts +0 -2
- package/dist/response/helpers/send-stream.d.ts +0 -3
- package/dist/response/helpers/send-web-blob.d.ts +0 -3
- package/dist/response/helpers/send-web-response.d.ts +0 -3
- package/dist/response/helpers/send.d.ts +0 -2
- package/dist/response/helpers/utils.d.ts +0 -2
- package/dist/response/index.d.ts +0 -3
- package/dist/response/module.d.ts +0 -3
- package/dist/response/types.d.ts +0 -3
- package/dist/router/constants.d.ts +0 -9
- package/dist/router/index.d.ts +0 -1
- package/dist/router/module.d.ts +0 -89
- package/dist/router/types.d.ts +0 -7
- package/dist/router/utils.d.ts +0 -3
- package/dist/router-options/index.d.ts +0 -2
- package/dist/router-options/module.d.ts +0 -4
- package/dist/router-options/transform.d.ts +0 -2
- package/dist/router-options/type.d.ts +0 -41
- package/dist/types.d.ts +0 -9
- package/dist/utils/cookie.d.ts +0 -1
- package/dist/utils/etag/index.d.ts +0 -3
- package/dist/utils/etag/module.d.ts +0 -11
- package/dist/utils/etag/type.d.ts +0 -15
- package/dist/utils/etag/utils.d.ts +0 -2
- package/dist/utils/index.d.ts +0 -13
- package/dist/utils/is-instance.d.ts +0 -1
- package/dist/utils/method.d.ts +0 -3
- package/dist/utils/mime.d.ts +0 -2
- package/dist/utils/next.d.ts +0 -2
- package/dist/utils/object.d.ts +0 -3
- package/dist/utils/path.d.ts +0 -5
- package/dist/utils/promise.d.ts +0 -1
- package/dist/utils/stream.d.ts +0 -6
- package/dist/utils/trust-proxy/index.d.ts +0 -2
- package/dist/utils/trust-proxy/module.d.ts +0 -2
- package/dist/utils/trust-proxy/type.d.ts +0 -2
- package/dist/utils/url.d.ts +0 -7
- package/dist/utils/web.d.ts +0 -3
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { MethodName } from '../../constants';
|
|
2
|
-
import type { RoutupError } from '../../error';
|
|
3
|
-
import type { Request } from '../../request';
|
|
4
|
-
import type { Response } from '../../response';
|
|
5
|
-
import type { Next } from '../../types';
|
|
6
|
-
import type { DispatchEventCreateContext } from './types';
|
|
7
|
-
export declare class DispatchEvent {
|
|
8
|
-
/**
|
|
9
|
-
* Request Object.
|
|
10
|
-
*/
|
|
11
|
-
request: Request;
|
|
12
|
-
/**
|
|
13
|
-
* Response Object.
|
|
14
|
-
*/
|
|
15
|
-
response: Response;
|
|
16
|
-
/**
|
|
17
|
-
* Params collected during execution.
|
|
18
|
-
*/
|
|
19
|
-
params: Record<string, any>;
|
|
20
|
-
/**
|
|
21
|
-
* Request path.
|
|
22
|
-
*/
|
|
23
|
-
path: string;
|
|
24
|
-
/**
|
|
25
|
-
* HTTP Method used for the request.
|
|
26
|
-
*/
|
|
27
|
-
method: `${MethodName}`;
|
|
28
|
-
/**
|
|
29
|
-
* The relative path on which the router is hung.
|
|
30
|
-
*/
|
|
31
|
-
mountPath: string;
|
|
32
|
-
/**
|
|
33
|
-
* The error which occurred during the dispatch process.
|
|
34
|
-
*/
|
|
35
|
-
error?: RoutupError;
|
|
36
|
-
/**
|
|
37
|
-
* Signal that the request hasn't been handled.
|
|
38
|
-
* Therefore, the request must be passed to the next handler or router in the chain.
|
|
39
|
-
*/
|
|
40
|
-
next: Next;
|
|
41
|
-
/**
|
|
42
|
-
* Indicate if the request has already been dispatched/send.
|
|
43
|
-
*/
|
|
44
|
-
protected _dispatched: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Ids of chained router instances.
|
|
47
|
-
*/
|
|
48
|
-
routerPath: number[];
|
|
49
|
-
/**
|
|
50
|
-
* Collected methods during dispatch process.
|
|
51
|
-
*/
|
|
52
|
-
methodsAllowed: string[];
|
|
53
|
-
constructor(context: DispatchEventCreateContext);
|
|
54
|
-
get dispatched(): boolean;
|
|
55
|
-
set dispatched(value: boolean);
|
|
56
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { MethodName } from '../../constants';
|
|
2
|
-
import type { Request } from '../../request';
|
|
3
|
-
import type { Response } from '../../response';
|
|
4
|
-
export type DispatchEventCreateContext = {
|
|
5
|
-
request: Request;
|
|
6
|
-
response: Response;
|
|
7
|
-
method?: `${MethodName}`;
|
|
8
|
-
path?: string;
|
|
9
|
-
};
|
package/dist/error/create.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Input } from '@ebec/http';
|
|
2
|
-
import { RoutupError } from './module';
|
|
3
|
-
/**
|
|
4
|
-
* Create an internal error object by
|
|
5
|
-
* - an existing error (accessible via cause property)
|
|
6
|
-
* - options
|
|
7
|
-
* - message
|
|
8
|
-
*
|
|
9
|
-
* @param input
|
|
10
|
-
*/
|
|
11
|
-
export declare function createError(input: Input | unknown): RoutupError;
|
package/dist/error/index.d.ts
DELETED
package/dist/error/is.d.ts
DELETED
package/dist/error/module.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Request } from '../../request';
|
|
2
|
-
import type { Response } from '../../response';
|
|
3
|
-
import type { Next } from '../../types';
|
|
4
|
-
import type { HandlerType } from '../constants';
|
|
5
|
-
import type { HandlerBaseConfig } from '../types-base';
|
|
6
|
-
export type CoreHandlerFn = (req: Request, res: Response, next: Next) => unknown | Promise<unknown>;
|
|
7
|
-
export type CoreHandlerConfig = HandlerBaseConfig & {
|
|
8
|
-
type: `${HandlerType.CORE}`;
|
|
9
|
-
fn: CoreHandlerFn;
|
|
10
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { RoutupError } from '../../error';
|
|
2
|
-
import type { Request } from '../../request';
|
|
3
|
-
import type { Response } from '../../response';
|
|
4
|
-
import type { Next } from '../../types';
|
|
5
|
-
import type { HandlerType } from '../constants';
|
|
6
|
-
import type { HandlerBaseConfig } from '../types-base';
|
|
7
|
-
export type ErrorHandlerFn = (err: RoutupError, req: Request, res: Response, next: Next) => unknown | Promise<unknown>;
|
|
8
|
-
export type ErrorHandlerConfig = HandlerBaseConfig & {
|
|
9
|
-
type: `${HandlerType.ERROR}`;
|
|
10
|
-
fn: ErrorHandlerFn;
|
|
11
|
-
};
|
package/dist/handler/index.d.ts
DELETED
package/dist/handler/is.d.ts
DELETED
package/dist/handler/module.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { MethodName } from '../constants';
|
|
2
|
-
import type { DispatchEvent, Dispatcher } from '../dispatcher';
|
|
3
|
-
import { HookManager } from '../hook';
|
|
4
|
-
import type { Path } from '../path';
|
|
5
|
-
import { PathMatcher } from '../path';
|
|
6
|
-
import type { HandlerConfig } from './types';
|
|
7
|
-
export declare class Handler implements Dispatcher {
|
|
8
|
-
readonly '@instanceof': symbol;
|
|
9
|
-
protected config: HandlerConfig;
|
|
10
|
-
protected hookManager: HookManager;
|
|
11
|
-
protected pathMatcher: PathMatcher | undefined;
|
|
12
|
-
protected _method: MethodName | undefined;
|
|
13
|
-
constructor(handler: HandlerConfig);
|
|
14
|
-
get type(): "error" | "core";
|
|
15
|
-
get path(): string | undefined;
|
|
16
|
-
get method(): MethodName | undefined;
|
|
17
|
-
dispatch(event: DispatchEvent): Promise<void>;
|
|
18
|
-
matchPath(path: string): boolean;
|
|
19
|
-
setPath(path?: Path): void;
|
|
20
|
-
matchMethod(method: `${MethodName}`): boolean;
|
|
21
|
-
setMethod(input?: `${MethodName}`): void;
|
|
22
|
-
protected mountHooks(): void;
|
|
23
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { MethodName } from '../constants';
|
|
2
|
-
import type { HookDefaultListener, HookErrorListener } from '../hook';
|
|
3
|
-
import type { Path } from '../path';
|
|
4
|
-
export type HandlerBaseConfig = {
|
|
5
|
-
method?: Uppercase<MethodName> | Lowercase<MethodName>;
|
|
6
|
-
path?: Path;
|
|
7
|
-
onError?: HookErrorListener;
|
|
8
|
-
onBefore?: HookDefaultListener;
|
|
9
|
-
onAfter?: HookDefaultListener;
|
|
10
|
-
};
|
package/dist/handler/types.d.ts
DELETED
package/dist/hook/constants.d.ts
DELETED
package/dist/hook/index.d.ts
DELETED
package/dist/hook/module.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { DispatchEvent } from '../dispatcher';
|
|
2
|
-
import { HookName } from './constants';
|
|
3
|
-
import type { HookListener, HookUnsubscribeFn } from './types';
|
|
4
|
-
export declare class HookManager {
|
|
5
|
-
protected items: Record<string, HookListener[]>;
|
|
6
|
-
constructor();
|
|
7
|
-
addListener(name: `${HookName}`, fn: HookListener): HookUnsubscribeFn;
|
|
8
|
-
removeListener(name: `${HookName}`): void;
|
|
9
|
-
removeListener(name: `${HookName}`, fn: HookListener): void;
|
|
10
|
-
/**
|
|
11
|
-
* @throws RoutupError
|
|
12
|
-
*
|
|
13
|
-
* @param name
|
|
14
|
-
* @param event
|
|
15
|
-
*/
|
|
16
|
-
trigger(name: `${HookName}`, event: DispatchEvent): Promise<void>;
|
|
17
|
-
private triggerListener;
|
|
18
|
-
private isErrorListenerHook;
|
|
19
|
-
}
|
package/dist/hook/types.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { DispatchErrorEvent, DispatchEvent } from '../dispatcher';
|
|
2
|
-
export type HookErrorListener = (event: DispatchErrorEvent) => Promise<unknown> | unknown;
|
|
3
|
-
export type HookDefaultListener = (event: DispatchEvent) => Promise<unknown> | unknown;
|
|
4
|
-
export type HookListener = HookErrorListener | HookDefaultListener;
|
|
5
|
-
export type HookUnsubscribeFn = () => void;
|