routup 3.0.0 → 3.1.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 +10 -8
- package/dist/adapters/node/module.d.ts +7 -0
- package/dist/{utils → adapters/raw}/header.d.ts +1 -1
- package/dist/{layer → adapters/raw}/index.d.ts +1 -1
- package/dist/adapters/raw/module.d.ts +4 -0
- package/dist/{dispatcher/adapters → adapters}/raw/type.d.ts +1 -1
- package/dist/adapters/web/module.d.ts +4 -0
- package/dist/constants.d.ts +7 -7
- package/dist/dispatcher/event/dispatch.d.ts +4 -0
- package/dist/dispatcher/event/error.d.ts +5 -0
- package/dist/dispatcher/event/index.d.ts +5 -0
- package/dist/dispatcher/event/is.d.ts +3 -0
- package/dist/dispatcher/event/module.d.ts +56 -0
- package/dist/dispatcher/event/types.d.ts +9 -0
- package/dist/dispatcher/index.d.ts +1 -2
- package/dist/dispatcher/type.d.ts +2 -30
- package/dist/error/create.d.ts +3 -3
- package/dist/error/is.d.ts +2 -2
- package/dist/error/module.d.ts +1 -1
- package/dist/handler/constants.d.ts +1 -0
- package/dist/handler/core/define.d.ts +4 -3
- package/dist/handler/core/types.d.ts +3 -3
- package/dist/handler/error/define.d.ts +4 -3
- package/dist/handler/error/types.d.ts +5 -5
- package/dist/handler/index.d.ts +1 -0
- package/dist/handler/is.d.ts +3 -1
- package/dist/handler/module.d.ts +23 -0
- package/dist/handler/types-base.d.ts +6 -2
- package/dist/handler/types.d.ts +3 -4
- package/dist/hook/constants.d.ts +8 -0
- package/dist/hook/index.d.ts +3 -0
- package/dist/hook/module.d.ts +19 -0
- package/dist/hook/types.d.ts +5 -0
- package/dist/index.cjs +629 -377
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +620 -370
- package/dist/index.mjs.map +1 -1
- package/dist/response/helpers/send-web-blob.d.ts +1 -1
- package/dist/response/helpers/send-web-response.d.ts +1 -1
- package/dist/router/constants.d.ts +8 -0
- package/dist/router/index.d.ts +0 -1
- package/dist/router/module.d.ts +56 -24
- package/dist/router/types.d.ts +7 -0
- package/dist/types.d.ts +1 -0
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/method.d.ts +3 -0
- package/dist/utils/next.d.ts +2 -0
- package/package.json +6 -6
- package/dist/dispatcher/adapters/node/module.d.ts +0 -7
- package/dist/dispatcher/adapters/raw/module.d.ts +0 -4
- package/dist/dispatcher/adapters/web/index.d.ts +0 -2
- package/dist/dispatcher/adapters/web/module.d.ts +0 -5
- package/dist/dispatcher/utils.d.ts +0 -5
- package/dist/layer/constants.d.ts +0 -1
- package/dist/layer/module.d.ts +0 -17
- package/dist/layer/type.d.ts +0 -8
- package/dist/layer/utils.d.ts +0 -2
- /package/dist/{dispatcher/adapters → adapters}/index.d.ts +0 -0
- /package/dist/{dispatcher/adapters → adapters}/node/index.d.ts +0 -0
- /package/dist/{dispatcher/adapters/raw → adapters/web}/index.d.ts +0 -0
- /package/dist/{dispatcher/adapters → adapters}/web/type.d.ts +0 -0
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { WebResponse } from '../../types';
|
|
2
2
|
import type { Response } from '../types';
|
|
3
|
-
export declare function sendWebResponse(res: Response, webResponse: WebResponse): Promise<
|
|
3
|
+
export declare function sendWebResponse(res: Response, webResponse: WebResponse): Promise<void>;
|
package/dist/router/index.d.ts
CHANGED
package/dist/router/module.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { MethodName } from '../constants';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
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';
|
|
5
7
|
import type { Path } from '../path';
|
|
6
8
|
import { PathMatcher } from '../path';
|
|
7
|
-
import type { RouterOptionsInput } from '../router-options';
|
|
8
9
|
import type { Plugin, PluginInstallContext } from '../plugin';
|
|
10
|
+
import type { RouterOptionsInput } from '../router-options';
|
|
11
|
+
import type { RouterPipelineContext } from './types';
|
|
9
12
|
export declare class Router implements Dispatcher {
|
|
10
13
|
readonly '@instanceof': symbol;
|
|
11
14
|
/**
|
|
@@ -21,37 +24,66 @@ export declare class Router implements Dispatcher {
|
|
|
21
24
|
*
|
|
22
25
|
* @protected
|
|
23
26
|
*/
|
|
24
|
-
protected stack: (Router |
|
|
27
|
+
protected stack: (Router | Handler)[];
|
|
25
28
|
/**
|
|
26
29
|
* Path matcher for the current mount path.
|
|
27
30
|
*
|
|
28
31
|
* @protected
|
|
29
32
|
*/
|
|
30
33
|
protected pathMatcher: PathMatcher | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* A hook manager.
|
|
36
|
+
*
|
|
37
|
+
* @protected
|
|
38
|
+
*/
|
|
39
|
+
protected hookManager: HookManager;
|
|
31
40
|
constructor(options?: RouterOptionsInput);
|
|
32
|
-
setPath(value?: Path): void;
|
|
33
41
|
matchPath(path: string): boolean;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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;
|
|
50
66
|
use(router: Router): this;
|
|
51
|
-
use(handler: Handler): this;
|
|
67
|
+
use(handler: Handler | HandlerConfig): this;
|
|
52
68
|
use(plugin: Plugin): this;
|
|
53
69
|
use(path: Path, router: Router): this;
|
|
54
|
-
use(path: Path, handler: Handler): this;
|
|
70
|
+
use(path: Path, handler: Handler | HandlerConfig): this;
|
|
55
71
|
use(path: Path, plugin: Plugin): this;
|
|
56
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;
|
|
57
89
|
}
|
package/dist/types.d.ts
CHANGED
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export * from './cookie';
|
|
2
|
-
export * from './header';
|
|
3
2
|
export * from './etag';
|
|
4
3
|
export * from './trust-proxy';
|
|
5
4
|
export * from './is-instance';
|
|
6
5
|
export * from './mime';
|
|
6
|
+
export * from './method';
|
|
7
|
+
export * from './next';
|
|
7
8
|
export * from './object';
|
|
8
9
|
export * from './path';
|
|
9
10
|
export * from './promise';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "routup",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Routup is a minimalistic http based routing framework.",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package.json": "./package.json",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"homepage": "https://github.com/routup/routup#readme",
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@ebec/http": "^2.
|
|
53
|
+
"@ebec/http": "^2.3.0",
|
|
54
54
|
"buffer": "^6.0.3",
|
|
55
55
|
"mime-explorer": "^1.0.0",
|
|
56
56
|
"negotiator": "^0.6.3",
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
"uncrypto": "^0.1.3"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@rollup/plugin-commonjs": "^25.0.
|
|
65
|
-
"@rollup/plugin-node-resolve": "^15.2.
|
|
66
|
-
"@swc/core": "^1.3.
|
|
64
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
65
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
66
|
+
"@swc/core": "^1.3.93",
|
|
67
67
|
"@swc/jest": "^0.2.29",
|
|
68
68
|
"@tada5hi/commitlint-config": "^1.1.2",
|
|
69
69
|
"@tada5hi/eslint-config-typescript": "^1.2.5",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"cross-env": "^7.0.3",
|
|
79
79
|
"jest": "^29.7.0",
|
|
80
80
|
"rimraf": "^5.0.5",
|
|
81
|
-
"rollup": "^
|
|
81
|
+
"rollup": "^4.1.4",
|
|
82
82
|
"semantic-release": "^22.0.5",
|
|
83
83
|
"supertest": "^6.3.3",
|
|
84
84
|
"typescript": "5.2.2"
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { RequestListener } from 'node:http';
|
|
3
|
-
import type { Request } from '../../../request';
|
|
4
|
-
import type { Response } from '../../../response';
|
|
5
|
-
import type { Router } from '../../../router';
|
|
6
|
-
export declare function dispatchNodeRequest(router: Router, req: Request, res: Response): Promise<void>;
|
|
7
|
-
export declare function createNodeDispatcher(router: Router): RequestListener;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Router } from '../../../router';
|
|
2
|
-
import type { DispatchRawRequestOptions, RawRequest, RawResponse } from './type';
|
|
3
|
-
export declare function dispatchRawRequest(router: Router, request: RawRequest, options?: DispatchRawRequestOptions): Promise<RawResponse>;
|
|
4
|
-
export declare function createRawDispatcher(router: Router): (request: RawRequest) => Promise<RawResponse>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Router } from '../../../router';
|
|
2
|
-
import type { WebRequest } from '../../../types';
|
|
3
|
-
import type { DispatchWebRequestOptions } from './type';
|
|
4
|
-
export declare function dispatchWebRequest(router: Router, request: WebRequest, options?: DispatchWebRequestOptions): Promise<Response>;
|
|
5
|
-
export declare function createWebDispatcher(router: Router): (request: WebRequest) => Promise<Response>;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { DispatcherMeta } from './type';
|
|
2
|
-
export declare function buildDispatcherMeta(input: Partial<DispatcherMeta>): DispatcherMeta;
|
|
3
|
-
export declare function cloneDispatcherMeta(input: DispatcherMeta): DispatcherMeta;
|
|
4
|
-
export declare function cloneDispatcherMetaParams(input?: Record<string, any>): Record<string, any>;
|
|
5
|
-
export declare function mergeDispatcherMetaParams(t1?: Record<string, any>, t2?: Record<string, any>): Record<string, any>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const LayerSymbol: unique symbol;
|
package/dist/layer/module.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Dispatcher, DispatcherEvent, DispatcherMeta } from '../dispatcher';
|
|
2
|
-
import type { Handler } from '../handler';
|
|
3
|
-
import { PathMatcher } from '../path';
|
|
4
|
-
import type { Response } from '../response';
|
|
5
|
-
export declare class Layer implements Dispatcher {
|
|
6
|
-
readonly '@instanceof': symbol;
|
|
7
|
-
protected handler: Handler;
|
|
8
|
-
protected pathMatcher: PathMatcher | undefined;
|
|
9
|
-
constructor(handler: Handler);
|
|
10
|
-
get type(): "error" | "core";
|
|
11
|
-
get path(): import("../path").Path | undefined;
|
|
12
|
-
get method(): string | undefined;
|
|
13
|
-
dispatch(event: DispatcherEvent, meta: DispatcherMeta): Promise<boolean>;
|
|
14
|
-
protected sendOutput(res: Response, input: unknown): Promise<any>;
|
|
15
|
-
matchPath(path: string): boolean;
|
|
16
|
-
matchMethod(method: string): boolean;
|
|
17
|
-
}
|
package/dist/layer/type.d.ts
DELETED
package/dist/layer/utils.d.ts
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|