routup 1.0.3 → 3.0.0-alpha.1
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 +163 -26
- package/dist/dispatcher/adapters/index.d.ts +3 -0
- package/dist/dispatcher/adapters/node/index.d.ts +1 -0
- package/dist/dispatcher/adapters/node/module.d.ts +7 -0
- package/dist/dispatcher/adapters/raw/module.d.ts +4 -0
- package/dist/dispatcher/adapters/raw/type.d.ts +18 -0
- package/dist/{route → dispatcher/adapters/web}/index.d.ts +0 -1
- package/dist/dispatcher/adapters/web/module.d.ts +5 -0
- package/dist/dispatcher/adapters/web/type.d.ts +3 -0
- package/dist/dispatcher/index.d.ts +3 -0
- package/dist/dispatcher/type.d.ts +32 -0
- package/dist/dispatcher/utils.d.ts +5 -0
- package/dist/error/create.d.ts +11 -0
- package/dist/error/index.d.ts +3 -0
- package/dist/error/is.d.ts +2 -0
- package/dist/error/module.d.ts +3 -0
- package/dist/handler/constants.d.ts +4 -0
- package/dist/handler/core/define.d.ts +3 -0
- package/dist/handler/core/index.d.ts +2 -0
- package/dist/handler/core/types.d.ts +10 -0
- package/dist/handler/error/define.d.ts +3 -0
- package/dist/handler/error/index.d.ts +2 -0
- package/dist/handler/error/types.d.ts +11 -0
- package/dist/handler/index.d.ts +6 -1
- package/dist/handler/is.d.ts +2 -0
- package/dist/handler/types-base.d.ts +6 -0
- package/dist/handler/types.d.ts +5 -0
- package/dist/index.cjs +1202 -629
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.mjs +1172 -597
- package/dist/index.mjs.map +1 -1
- package/dist/layer/constants.d.ts +1 -0
- package/dist/layer/module.d.ts +13 -10
- package/dist/layer/type.d.ts +6 -4
- package/dist/path/index.d.ts +1 -0
- package/dist/path/matcher.d.ts +5 -6
- package/dist/path/type.d.ts +1 -0
- package/dist/path/utils.d.ts +2 -0
- package/dist/plugin/index.d.ts +2 -0
- package/dist/plugin/is.d.ts +2 -0
- package/dist/plugin/types.d.ts +32 -0
- package/dist/{helpers/request → request/helpers}/body.d.ts +1 -1
- package/dist/{helpers/request → request/helpers}/cache.d.ts +1 -1
- package/dist/{helpers/request → request/helpers}/cookie.d.ts +1 -1
- package/dist/{helpers/request → request/helpers}/env.d.ts +1 -1
- package/dist/{helpers/request → request/helpers}/header-accept-charset.d.ts +1 -1
- package/dist/{helpers/request → request/helpers}/header-accept-language.d.ts +1 -1
- package/dist/{helpers/request → request/helpers}/header-accept.d.ts +1 -1
- package/dist/{helpers/request → request/helpers}/header-content-type.d.ts +1 -1
- package/dist/{helpers/request → request/helpers}/header.d.ts +1 -1
- package/dist/{helpers/request → request/helpers}/hostname.d.ts +1 -1
- package/dist/{helpers/request → request/helpers}/index.d.ts +1 -0
- package/dist/{helpers/request → request/helpers}/ip.d.ts +1 -1
- package/dist/{helpers/request → request/helpers}/mount-path.d.ts +1 -1
- package/dist/{helpers/request → request/helpers}/negotiator.d.ts +1 -1
- package/dist/{helpers/request → request/helpers}/params.d.ts +1 -1
- package/dist/{helpers/request → request/helpers}/path.d.ts +1 -1
- package/dist/{helpers/request → request/helpers}/protocol.d.ts +1 -1
- package/dist/{helpers/request → request/helpers}/query.d.ts +1 -1
- package/dist/request/helpers/router.d.ts +3 -0
- package/dist/request/index.d.ts +3 -0
- package/dist/request/module.d.ts +4 -0
- package/dist/request/types.d.ts +13 -0
- package/dist/{helpers/response → response/helpers}/cache.d.ts +1 -1
- package/dist/response/helpers/gone.d.ts +2 -0
- package/dist/{helpers/response → response/helpers}/header-attachment.d.ts +1 -1
- package/dist/{helpers/response → response/helpers}/header-content-type.d.ts +1 -1
- package/dist/{helpers/response → response/helpers}/header.d.ts +1 -1
- package/dist/{helpers/response → response/helpers}/index.d.ts +3 -0
- package/dist/{helpers/response → response/helpers}/send-accepted.d.ts +2 -2
- package/dist/{helpers/response → response/helpers}/send-created.d.ts +2 -2
- package/dist/response/helpers/send-file.d.ts +17 -0
- package/dist/{helpers/response → response/helpers}/send-format.d.ts +1 -1
- package/dist/response/helpers/send-redirect.d.ts +2 -0
- package/dist/response/helpers/send-stream.d.ts +3 -0
- package/dist/response/helpers/send-web-blob.d.ts +3 -0
- package/dist/response/helpers/send-web-response.d.ts +3 -0
- package/dist/response/helpers/send.d.ts +2 -0
- package/dist/response/helpers/utils.d.ts +2 -0
- package/dist/response/index.d.ts +3 -0
- package/dist/response/module.d.ts +3 -0
- package/dist/response/types.d.ts +4 -0
- package/dist/router/constants.d.ts +1 -0
- package/dist/router/index.d.ts +1 -1
- package/dist/router/module.d.ts +34 -50
- package/dist/router/utils.d.ts +3 -0
- package/dist/router-options/index.d.ts +2 -0
- package/dist/router-options/module.d.ts +4 -0
- package/dist/router-options/transform.d.ts +2 -0
- package/dist/router-options/type.d.ts +41 -0
- package/dist/types.d.ts +10 -0
- package/dist/utils/cookie.d.ts +1 -0
- package/dist/utils/etag/module.d.ts +4 -3
- package/dist/utils/etag/type.d.ts +1 -1
- package/dist/utils/header.d.ts +3 -0
- package/dist/utils/index.d.ts +4 -1
- package/dist/utils/is-instance.d.ts +1 -1
- package/dist/utils/path.d.ts +5 -2
- package/dist/utils/stream.d.ts +8 -0
- package/dist/utils/web.d.ts +3 -0
- package/package.json +21 -19
- package/dist/config/module.d.ts +0 -8
- package/dist/config/type.d.ts +0 -34
- package/dist/handler/utils.d.ts +0 -2
- package/dist/helpers/index.d.ts +0 -2
- package/dist/helpers/response/send-file.d.ts +0 -9
- package/dist/helpers/response/send-redirect.d.ts +0 -2
- package/dist/helpers/response/send-stream.d.ts +0 -4
- package/dist/helpers/response/send.d.ts +0 -2
- package/dist/helpers/response/utils.d.ts +0 -3
- package/dist/route/module.d.ts +0 -27
- package/dist/route/type.d.ts +0 -6
- package/dist/route/utils.d.ts +0 -2
- package/dist/router/type.d.ts +0 -24
- package/dist/type.d.ts +0 -24
- package/dist/utils/request.d.ts +0 -2
- /package/dist/{config → dispatcher/adapters/raw}/index.d.ts +0 -0
- /package/dist/{helpers/request → request/helpers}/header-accept-encoding.d.ts +0 -0
|
@@ -12,5 +12,5 @@ export type EtagOptions = {
|
|
|
12
12
|
*/
|
|
13
13
|
threshold?: number;
|
|
14
14
|
};
|
|
15
|
-
export type EtagFn = (body: any, encoding?: BufferEncoding, size?: number) => string | undefined
|
|
15
|
+
export type EtagFn = (body: any, encoding?: BufferEncoding, size?: number) => Promise<string | undefined>;
|
|
16
16
|
export type EtagInput = boolean | EtagOptions | EtagFn;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { RawResponseHeader } from '../dispatcher';
|
|
2
|
+
export declare function transformHeaderToTuples(key: string, value: RawResponseHeader): [string, string][];
|
|
3
|
+
export declare function transformHeadersToTuples(input: Record<string, RawResponseHeader>): [string, string][];
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export * from './cookie';
|
|
2
|
+
export * from './header';
|
|
1
3
|
export * from './etag';
|
|
2
4
|
export * from './trust-proxy';
|
|
3
5
|
export * from './is-instance';
|
|
@@ -5,5 +7,6 @@ export * from './mime';
|
|
|
5
7
|
export * from './object';
|
|
6
8
|
export * from './path';
|
|
7
9
|
export * from './promise';
|
|
8
|
-
export * from './
|
|
10
|
+
export * from './stream';
|
|
9
11
|
export * from './url';
|
|
12
|
+
export * from './web';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function isInstance(input: unknown,
|
|
1
|
+
export declare function isInstance(input: unknown, sym: symbol): boolean;
|
package/dist/utils/path.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import type { ReadableStream as WebReadableStream } from 'stream/web';
|
|
4
|
+
import type { Readable as NodeReadable } from 'node:stream';
|
|
5
|
+
import type { Readable } from 'readable-stream';
|
|
6
|
+
export declare function isNodeStream(input: unknown): input is NodeReadable | Readable;
|
|
7
|
+
export declare function isWebStream(input: unknown): input is ReadableStream | WebReadableStream;
|
|
8
|
+
export declare function isStream(data: any): data is NodeReadable | Readable | ReadableStream | WebReadableStream;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "routup",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.1",
|
|
4
4
|
"description": "Routup is a minimalistic http based routing framework.",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package.json": "./package.json",
|
|
@@ -50,35 +50,37 @@
|
|
|
50
50
|
},
|
|
51
51
|
"homepage": "https://github.com/routup/routup#readme",
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@ebec/http": "^
|
|
54
|
-
"
|
|
53
|
+
"@ebec/http": "^2.2.1",
|
|
54
|
+
"buffer": "^6.0.3",
|
|
55
55
|
"mime-explorer": "^1.0.0",
|
|
56
56
|
"negotiator": "^0.6.3",
|
|
57
57
|
"path-to-regexp": "^6.2.1",
|
|
58
58
|
"proxy-addr": "^2.0.7",
|
|
59
|
-
"
|
|
60
|
-
"
|
|
59
|
+
"readable-stream": "^4.4.2",
|
|
60
|
+
"smob": "^1.4.1",
|
|
61
|
+
"uncrypto": "^0.1.3"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
64
|
"@rollup/plugin-commonjs": "^25.0.4",
|
|
64
|
-
"@rollup/plugin-node-resolve": "^15.1
|
|
65
|
-
"@swc/core": "^1.3.
|
|
65
|
+
"@rollup/plugin-node-resolve": "^15.2.1",
|
|
66
|
+
"@swc/core": "^1.3.90",
|
|
66
67
|
"@swc/jest": "^0.2.29",
|
|
67
|
-
"@tada5hi/commitlint-config": "^1.1.
|
|
68
|
-
"@tada5hi/eslint-config-typescript": "^1.2.
|
|
69
|
-
"@tada5hi/semantic-release": "^0.
|
|
68
|
+
"@tada5hi/commitlint-config": "^1.1.2",
|
|
69
|
+
"@tada5hi/eslint-config-typescript": "^1.2.5",
|
|
70
|
+
"@tada5hi/semantic-release": "^0.3.0",
|
|
70
71
|
"@tada5hi/tsconfig": "^0.5.0",
|
|
71
|
-
"@types/jest": "^29.5.
|
|
72
|
+
"@types/jest": "^29.5.5",
|
|
72
73
|
"@types/negotiator": "^0.6.1",
|
|
73
|
-
"@types/node": "^20.
|
|
74
|
-
"@types/proxy-addr": "^2.0.
|
|
75
|
-
"@types/
|
|
74
|
+
"@types/node": "^20.7.1",
|
|
75
|
+
"@types/proxy-addr": "^2.0.1",
|
|
76
|
+
"@types/readable-stream": "^4.0.3",
|
|
77
|
+
"@types/supertest": "^2.0.13",
|
|
76
78
|
"cross-env": "^7.0.3",
|
|
77
|
-
"jest": "^29.
|
|
78
|
-
"rimraf": "^5.0.
|
|
79
|
-
"rollup": "^3.
|
|
80
|
-
"semantic-release": "^
|
|
79
|
+
"jest": "^29.7.0",
|
|
80
|
+
"rimraf": "^5.0.5",
|
|
81
|
+
"rollup": "^3.29.4",
|
|
82
|
+
"semantic-release": "^22.0.5",
|
|
81
83
|
"supertest": "^6.3.3",
|
|
82
|
-
"typescript": "5.
|
|
84
|
+
"typescript": "5.2.2"
|
|
83
85
|
}
|
|
84
86
|
}
|
package/dist/config/module.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { FlattenObject } from 'continu';
|
|
2
|
-
import { Continu } from 'continu';
|
|
3
|
-
import type { Options, OptionsInput } from './type';
|
|
4
|
-
export declare function buildConfig(): Continu<Options, OptionsInput>;
|
|
5
|
-
export declare function useConfig(): Continu<Options, OptionsInput>;
|
|
6
|
-
export declare function setConfig(config: Continu<Options, OptionsInput>): void;
|
|
7
|
-
export declare function setConfigOption<K extends keyof FlattenObject<OptionsInput>>(key: K, value: FlattenObject<OptionsInput>[K]): Options;
|
|
8
|
-
export declare function getConfigOption(key: keyof FlattenObject<OptionsInput>): string | number | import("../utils").EtagFn | import("../utils").TrustProxyFn;
|
package/dist/config/type.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { EtagFn, EtagInput } from '../utils/etag/type';
|
|
2
|
-
import type { TrustProxyFn, TrustProxyInput } from '../utils/trust-proxy';
|
|
3
|
-
export type Options = {
|
|
4
|
-
/**
|
|
5
|
-
* default: production
|
|
6
|
-
*/
|
|
7
|
-
env: string;
|
|
8
|
-
/**
|
|
9
|
-
* default: () => true
|
|
10
|
-
*/
|
|
11
|
-
etag: EtagFn;
|
|
12
|
-
/**
|
|
13
|
-
* default: 2
|
|
14
|
-
*/
|
|
15
|
-
subdomainOffset: number;
|
|
16
|
-
/**
|
|
17
|
-
* default: () => false
|
|
18
|
-
*/
|
|
19
|
-
trustProxy: TrustProxyFn;
|
|
20
|
-
/**
|
|
21
|
-
* default: 0
|
|
22
|
-
*/
|
|
23
|
-
proxyIpMax: number;
|
|
24
|
-
};
|
|
25
|
-
export type OptionsInput = {
|
|
26
|
-
/**
|
|
27
|
-
* default: true
|
|
28
|
-
*/
|
|
29
|
-
etag?: EtagInput;
|
|
30
|
-
/**
|
|
31
|
-
* default: false
|
|
32
|
-
*/
|
|
33
|
-
trustProxy?: TrustProxyInput;
|
|
34
|
-
} & Partial<Omit<Options, 'etag' | 'trustProxy'>>;
|
package/dist/handler/utils.d.ts
DELETED
package/dist/helpers/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { Stats } from 'node:fs';
|
|
3
|
-
import type { Response } from '../../type';
|
|
4
|
-
export type SendFileOptions = {
|
|
5
|
-
stats?: Stats;
|
|
6
|
-
filePath: string;
|
|
7
|
-
attachment?: boolean;
|
|
8
|
-
};
|
|
9
|
-
export declare function sendFile(res: Response, filePath: string | SendFileOptions, fn?: CallableFunction): void;
|
package/dist/route/module.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { MethodName } from '../constants';
|
|
2
|
-
import type { DispatcherMeta, Handler, Next, Path, Request, Response } from '../type';
|
|
3
|
-
import { Layer } from '../layer';
|
|
4
|
-
import type { PathMatcherOptions } from '../path';
|
|
5
|
-
import { PathMatcher } from '../path';
|
|
6
|
-
import type { RouteOptions } from './type';
|
|
7
|
-
export declare class Route {
|
|
8
|
-
readonly '@instanceof': symbol;
|
|
9
|
-
path: Path;
|
|
10
|
-
protected pathMatcher: PathMatcher;
|
|
11
|
-
protected pathMatcherOptions: PathMatcherOptions;
|
|
12
|
-
protected layers: Record<string, Layer[]>;
|
|
13
|
-
constructor(options: RouteOptions);
|
|
14
|
-
matchPath(path: string): boolean;
|
|
15
|
-
matchMethod(method: string): boolean;
|
|
16
|
-
getMethods(): string[];
|
|
17
|
-
dispatch(req: Request, res: Response, meta: DispatcherMeta, done: Next): void;
|
|
18
|
-
register(method: `${MethodName}`, ...handlers: Handler[]): void;
|
|
19
|
-
get(...handlers: Handler[]): void;
|
|
20
|
-
post(...handlers: Handler[]): void;
|
|
21
|
-
put(...handlers: Handler[]): void;
|
|
22
|
-
patch(...handlers: Handler[]): void;
|
|
23
|
-
delete(...handlers: Handler[]): void;
|
|
24
|
-
head(...handlers: Handler[]): void;
|
|
25
|
-
options(...handlers: Handler[]): void;
|
|
26
|
-
private isStrictPath;
|
|
27
|
-
}
|
package/dist/route/type.d.ts
DELETED
package/dist/route/utils.d.ts
DELETED
package/dist/router/type.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { PathMatcherOptions } from '../path';
|
|
2
|
-
import type { Path } from '../type';
|
|
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
|
-
* Path matcher options.
|
|
13
|
-
*
|
|
14
|
-
* @default: {end: false, sensitive: true}
|
|
15
|
-
*/
|
|
16
|
-
pathMatcher?: PathMatcherOptions;
|
|
17
|
-
/**
|
|
18
|
-
* Milliseconds (ms) until the request should be canceled.
|
|
19
|
-
*
|
|
20
|
-
* @type number
|
|
21
|
-
* @default undefined
|
|
22
|
-
*/
|
|
23
|
-
timeout?: number;
|
|
24
|
-
};
|
package/dist/type.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
-
export interface Response extends ServerResponse {
|
|
4
|
-
}
|
|
5
|
-
export interface Request extends IncomingMessage {
|
|
6
|
-
}
|
|
7
|
-
export type Next = (err?: Error) => void;
|
|
8
|
-
export type Handler = (req: Request, res: Response, next: Next) => unknown;
|
|
9
|
-
export type ErrorHandler = (err: Error, req: Request, res: Response, next: Next) => unknown;
|
|
10
|
-
export type Path = string | RegExp;
|
|
11
|
-
export type DispatcherMeta = {
|
|
12
|
-
/**
|
|
13
|
-
* Params collected on path.
|
|
14
|
-
*/
|
|
15
|
-
params?: Record<string, any>;
|
|
16
|
-
/**
|
|
17
|
-
* Path to check for the current instance.
|
|
18
|
-
*/
|
|
19
|
-
path?: string;
|
|
20
|
-
/**
|
|
21
|
-
* The relative path on which the router is hung.
|
|
22
|
-
*/
|
|
23
|
-
mountPath?: string;
|
|
24
|
-
};
|
package/dist/utils/request.d.ts
DELETED
|
File without changes
|
|
File without changes
|