routup 2.0.0 → 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 +88 -35
- package/dist/dispatcher/adapters/node/module.d.ts +2 -1
- package/dist/dispatcher/type.d.ts +8 -6
- package/dist/dispatcher/utils.d.ts +2 -1
- 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 -0
- 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 +732 -695
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.mjs +724 -693
- package/dist/index.mjs.map +1 -1
- package/dist/layer/constants.d.ts +1 -0
- package/dist/layer/module.d.ts +9 -7
- package/dist/layer/type.d.ts +6 -3
- package/dist/layer/utils.d.ts +1 -1
- package/dist/path/matcher.d.ts +4 -4
- 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/request/helpers/body.d.ts +1 -1
- package/dist/request/helpers/cache.d.ts +1 -1
- package/dist/request/helpers/cookie.d.ts +1 -1
- package/dist/request/helpers/env.d.ts +1 -1
- package/dist/request/helpers/header-accept-charset.d.ts +1 -1
- package/dist/request/helpers/header-accept-language.d.ts +1 -1
- package/dist/request/helpers/header-accept.d.ts +1 -1
- package/dist/request/helpers/header-content-type.d.ts +1 -1
- package/dist/request/helpers/header.d.ts +1 -1
- package/dist/request/helpers/hostname.d.ts +1 -1
- package/dist/request/helpers/ip.d.ts +1 -1
- package/dist/request/helpers/mount-path.d.ts +1 -1
- package/dist/request/helpers/negotiator.d.ts +1 -1
- package/dist/request/helpers/params.d.ts +1 -1
- package/dist/request/helpers/path.d.ts +1 -1
- package/dist/request/helpers/protocol.d.ts +1 -1
- package/dist/request/helpers/query.d.ts +1 -1
- package/dist/request/helpers/router.d.ts +3 -3
- package/dist/request/types.d.ts +4 -0
- package/dist/response/helpers/cache.d.ts +1 -1
- package/dist/response/helpers/gone.d.ts +1 -1
- package/dist/response/helpers/header-attachment.d.ts +1 -1
- package/dist/response/helpers/header-content-type.d.ts +1 -1
- package/dist/response/helpers/header.d.ts +1 -1
- package/dist/response/helpers/send-accepted.d.ts +1 -1
- package/dist/response/helpers/send-created.d.ts +1 -1
- package/dist/response/helpers/send-file.d.ts +1 -1
- package/dist/response/helpers/send-format.d.ts +1 -1
- package/dist/response/helpers/send-redirect.d.ts +1 -1
- package/dist/response/helpers/send-stream.d.ts +2 -1
- package/dist/response/helpers/send-web-blob.d.ts +2 -1
- package/dist/response/helpers/send-web-response.d.ts +2 -1
- package/dist/response/helpers/send.d.ts +1 -1
- package/dist/response/helpers/utils.d.ts +1 -1
- package/dist/response/index.d.ts +1 -0
- package/dist/response/module.d.ts +2 -1
- package/dist/response/types.d.ts +4 -0
- package/dist/router/constants.d.ts +1 -0
- package/dist/router/index.d.ts +1 -0
- package/dist/router/module.d.ts +26 -23
- package/dist/router/utils.d.ts +2 -0
- package/dist/router-options/module.d.ts +1 -1
- package/dist/router-options/type.d.ts +3 -12
- package/dist/types.d.ts +0 -9
- package/dist/utils/is-instance.d.ts +1 -1
- package/package.json +15 -14
- package/dist/error.d.ts +0 -1
- package/dist/route/index.d.ts +0 -3
- package/dist/route/module.d.ts +0 -28
- package/dist/route/type.d.ts +0 -6
- package/dist/route/utils.d.ts +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LayerSymbol: unique symbol;
|
package/dist/layer/module.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import type { Dispatcher, DispatcherEvent, DispatcherMeta } from '../dispatcher';
|
|
2
|
+
import type { Handler } from '../handler';
|
|
2
3
|
import { PathMatcher } from '../path';
|
|
3
|
-
import type { Response } from '../
|
|
4
|
-
import type { LayerOptions } from './type';
|
|
4
|
+
import type { Response } from '../response';
|
|
5
5
|
export declare class Layer implements Dispatcher {
|
|
6
6
|
readonly '@instanceof': symbol;
|
|
7
|
-
protected
|
|
8
|
-
protected pathMatcher: PathMatcher;
|
|
9
|
-
constructor(
|
|
10
|
-
|
|
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;
|
|
11
13
|
dispatch(event: DispatcherEvent, meta: DispatcherMeta): Promise<boolean>;
|
|
12
14
|
protected sendOutput(res: Response, input: unknown): Promise<any>;
|
|
13
15
|
matchPath(path: string): boolean;
|
|
14
|
-
|
|
16
|
+
matchMethod(method: string): boolean;
|
|
15
17
|
}
|
package/dist/layer/type.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MethodName } from '../constants';
|
|
2
|
+
import type { HandlerFn } from '../handler';
|
|
3
|
+
import type { Path } from '../path';
|
|
2
4
|
export type LayerOptions = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
handler: HandlerFn;
|
|
6
|
+
method?: `${MethodName}`;
|
|
7
|
+
path?: Path;
|
|
5
8
|
};
|
package/dist/layer/utils.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Layer } from './module';
|
|
1
|
+
import type { Layer } from './module';
|
|
2
2
|
export declare function isLayerInstance(input: unknown): input is Layer;
|
package/dist/path/matcher.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Key } from 'path-to-regexp';
|
|
2
2
|
import type { Path, PathMatcherExecResult, PathMatcherOptions } from './type';
|
|
3
3
|
export declare class PathMatcher {
|
|
4
|
-
path: Path;
|
|
5
|
-
regexp: RegExp;
|
|
6
|
-
regexpKeys: Key[];
|
|
7
|
-
regexpOptions: PathMatcherOptions;
|
|
4
|
+
protected path: Path;
|
|
5
|
+
protected regexp: RegExp;
|
|
6
|
+
protected regexpKeys: Key[];
|
|
7
|
+
protected regexpOptions: PathMatcherOptions;
|
|
8
8
|
constructor(path: Path, options?: PathMatcherOptions);
|
|
9
9
|
test(path: string): boolean;
|
|
10
10
|
exec(path: string): PathMatcherExecResult | undefined;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Path } from '../path';
|
|
2
|
+
import type { Router } from '../router';
|
|
3
|
+
export type PluginOptions = Record<string | symbol, any>;
|
|
4
|
+
export type PluginInstallFn<Options extends PluginOptions = PluginOptions> = (router: Router, options: Options) => any;
|
|
5
|
+
export type Plugin<Options extends PluginOptions = PluginOptions> = {
|
|
6
|
+
/**
|
|
7
|
+
* The name of the plugin.
|
|
8
|
+
*/
|
|
9
|
+
name: string;
|
|
10
|
+
/**
|
|
11
|
+
* The supported routup (semver) version.
|
|
12
|
+
*/
|
|
13
|
+
version?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The installation function called on registration.
|
|
16
|
+
*/
|
|
17
|
+
install: PluginInstallFn<Options>;
|
|
18
|
+
};
|
|
19
|
+
export type PluginInstallContext<Options = any> = {
|
|
20
|
+
/**
|
|
21
|
+
* The name property overwrites the name defined by the plugin.
|
|
22
|
+
*/
|
|
23
|
+
name?: string;
|
|
24
|
+
/**
|
|
25
|
+
* By specifying a path, the plugin will be installed as a child router.
|
|
26
|
+
*/
|
|
27
|
+
path?: Path;
|
|
28
|
+
/**
|
|
29
|
+
* Pass options to the plugin installation routine.
|
|
30
|
+
*/
|
|
31
|
+
options: Options;
|
|
32
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Request } from '
|
|
1
|
+
import type { Request } from '../types';
|
|
2
2
|
export declare function useRequestBody(req: Request): Record<string, any>;
|
|
3
3
|
export declare function useRequestBody(req: Request, key: string): any | undefined;
|
|
4
4
|
export declare function hasRequestBody(req: Request): boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Request } from '
|
|
1
|
+
import type { Request } from '../types';
|
|
2
2
|
export declare function isRequestCacheable(req: Request, modifiedTime: string | Date): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Request } from '
|
|
1
|
+
import type { Request } from '../types';
|
|
2
2
|
export declare function useRequestCookies(req: Request): Record<string, string>;
|
|
3
3
|
export declare function hasRequestCookies(req: Request): boolean;
|
|
4
4
|
export declare function useRequestCookie(req: Request, name: string): string | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Request } from '
|
|
1
|
+
import type { Request } from '../types';
|
|
2
2
|
export declare function setRequestEnv(req: Request, key: string, value: unknown): void;
|
|
3
3
|
export declare function setRequestEnv(req: Request, record: Record<string, any>, append?: boolean): void;
|
|
4
4
|
export declare function useRequestEnv(req: Request): Record<string, any>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Request } from '
|
|
1
|
+
import type { Request } from '../types';
|
|
2
2
|
export declare function getRequestAcceptableCharsets(req: Request): string[];
|
|
3
3
|
export declare function getRequestAcceptableCharset(req: Request, input: string | string[]): string | undefined;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Request } from '
|
|
1
|
+
import type { Request } from '../types';
|
|
2
2
|
export declare function getRequestAcceptableLanguages(req: Request): string[];
|
|
3
3
|
export declare function getRequestAcceptableLanguage(req: Request, input?: string | string[]): string | undefined;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Request } from '
|
|
1
|
+
import type { Request } from '../types';
|
|
2
2
|
export declare function getRequestAcceptableContentTypes(req: Request): string[];
|
|
3
3
|
export declare function getRequestAcceptableContentType(req: Request, input?: string | string[]): string | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Request } from '
|
|
1
|
+
import type { Request } from '../types';
|
|
2
2
|
export declare function matchRequestContentType(req: Request, contentType: string): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { IncomingHttpHeaders } from 'node:http';
|
|
3
|
-
import type { Request } from '
|
|
3
|
+
import type { Request } from '../types';
|
|
4
4
|
export declare function getRequestHeader<K extends keyof IncomingHttpHeaders>(req: Request, name: K): IncomingHttpHeaders[K];
|
|
5
5
|
export declare function setRequestHeader<K extends keyof IncomingHttpHeaders>(req: Request, name: K, value: IncomingHttpHeaders[K]): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Request } from '
|
|
1
|
+
import type { Request } from '../types';
|
|
2
2
|
export declare function useRequestParams(req: Request): Record<string, any>;
|
|
3
3
|
export declare function useRequestParam(req: Request, key: string): any;
|
|
4
4
|
export declare function setRequestParams(req: Request, data: Record<string, any>): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Request } from '
|
|
1
|
+
import type { Request } from '../types';
|
|
2
2
|
export declare function useRequestPath(req: Request): string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Request } from '
|
|
1
|
+
import type { Request } from '../types';
|
|
2
2
|
export declare function useRequestQuery(req: Request): Record<string, any>;
|
|
3
3
|
export declare function useRequestQuery(req: Request, key: string): any;
|
|
4
4
|
export declare function hasRequestQuery(req: Request): boolean;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { Request } from '
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
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;
|
package/dist/request/types.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { IncomingMessage } from 'node:http';
|
|
1
3
|
import type { NodeReadableStream, WebReadableStream } from '../types';
|
|
2
4
|
export type RequestBody = null | Iterable<any> | AsyncIterable<any> | NodeReadableStream | WebReadableStream;
|
|
3
5
|
export type RequestHeaders = Record<string, string | string[]>;
|
|
@@ -7,3 +9,5 @@ export type RequestCreateContext = {
|
|
|
7
9
|
method?: string;
|
|
8
10
|
url?: string;
|
|
9
11
|
};
|
|
12
|
+
export interface Request extends IncomingMessage {
|
|
13
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Response } from '
|
|
1
|
+
import type { Response } from '../types';
|
|
2
2
|
export declare function isResponseGone(res: Response): any;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Response } from '
|
|
1
|
+
import type { Response } from '../types';
|
|
2
2
|
export declare function setResponseHeaderAttachment(res: Response, filename?: string): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Response } from '
|
|
1
|
+
import type { Response } from '../types';
|
|
2
2
|
export declare function setResponseHeaderContentType(res: Response, input: string, ifNotExists?: boolean): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { OutgoingHttpHeader } from 'node:http';
|
|
3
|
-
import type { Response } from '
|
|
3
|
+
import type { Response } from '../types';
|
|
4
4
|
export declare function appendResponseHeader(res: Response, name: string, value: OutgoingHttpHeader): void;
|
|
5
5
|
export declare function appendResponseHeaderDirective(res: Response, name: string, value: OutgoingHttpHeader): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Response } from '
|
|
1
|
+
import type { Response } from '../types';
|
|
2
2
|
export declare function sendAccepted(res: Response, chunk?: any): Promise<void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Response } from '
|
|
1
|
+
import type { Response } from '../types';
|
|
2
2
|
export declare function sendCreated(res: Response, chunk?: any): Promise<void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Response } from '
|
|
1
|
+
import type { Response } from '../types';
|
|
2
2
|
export declare function sendRedirect(res: Response, location: string, statusCode?: number): Promise<void>;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import type { NodeReadableStream,
|
|
1
|
+
import type { NodeReadableStream, WebReadableStream } from '../../types';
|
|
2
|
+
import type { Response } from '../types';
|
|
2
3
|
export declare function sendStream(res: Response, stream: NodeReadableStream | WebReadableStream, next?: (err?: Error) => Promise<unknown> | unknown): Promise<unknown>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Response } from '
|
|
1
|
+
import type { Response } from '../types';
|
|
2
2
|
export declare function send(res: Response, chunk?: any): Promise<void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { Response } from '
|
|
1
|
+
import type { Response } from '../types';
|
|
2
2
|
export declare function setResponseContentTypeByFileName(res: Response, fileName: string): void;
|
package/dist/response/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RouterSymbol: unique symbol;
|
package/dist/router/index.d.ts
CHANGED
package/dist/router/module.d.ts
CHANGED
|
@@ -1,51 +1,54 @@
|
|
|
1
1
|
import type { Dispatcher, DispatcherEvent, DispatcherMeta } from '../dispatcher';
|
|
2
|
-
import type {
|
|
3
|
-
import type { Path, PathMatcherOptions } from '../path';
|
|
4
|
-
import { PathMatcher } from '../path';
|
|
2
|
+
import type { Handler } from '../handler';
|
|
5
3
|
import { Layer } from '../layer';
|
|
6
|
-
import {
|
|
4
|
+
import type { Path } from '../path';
|
|
5
|
+
import { PathMatcher } from '../path';
|
|
7
6
|
import type { RouterOptionsInput } from '../router-options';
|
|
8
|
-
|
|
7
|
+
import type { Plugin, PluginInstallContext, PluginOptions } from '../plugin';
|
|
9
8
|
export declare class Router implements Dispatcher {
|
|
10
9
|
readonly '@instanceof': symbol;
|
|
11
10
|
/**
|
|
12
11
|
* An identifier for the router instance.
|
|
13
12
|
*/
|
|
14
13
|
readonly id: number;
|
|
14
|
+
/**
|
|
15
|
+
* A label for the router instance.
|
|
16
|
+
*/
|
|
17
|
+
readonly name?: string;
|
|
15
18
|
/**
|
|
16
19
|
* Array of mounted layers, routes & routers.
|
|
17
20
|
*
|
|
18
21
|
* @protected
|
|
19
22
|
*/
|
|
20
|
-
protected stack: (Router |
|
|
23
|
+
protected stack: (Router | Layer)[];
|
|
21
24
|
/**
|
|
22
25
|
* Path matcher for the current mount path.
|
|
23
26
|
*
|
|
24
27
|
* @protected
|
|
25
28
|
*/
|
|
26
29
|
protected pathMatcher: PathMatcher | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* Path matcher options.
|
|
29
|
-
*
|
|
30
|
-
* @protected
|
|
31
|
-
*/
|
|
32
|
-
protected pathMatcherOptions: PathMatcherOptions | undefined;
|
|
33
30
|
constructor(options?: RouterOptionsInput);
|
|
34
31
|
setPath(value?: Path): void;
|
|
35
32
|
matchPath(path: string): boolean;
|
|
36
|
-
dispatch(event: DispatcherEvent, meta
|
|
37
|
-
|
|
38
|
-
delete(path: Path,
|
|
39
|
-
get(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
dispatch(event: DispatcherEvent, meta: DispatcherMeta): Promise<boolean>;
|
|
34
|
+
delete(handler: Handler): this;
|
|
35
|
+
delete(path: Path, handler: Handler): this;
|
|
36
|
+
get(handler: Handler): this;
|
|
37
|
+
get(path: Path, handler: Handler): this;
|
|
38
|
+
post(handler: Handler): this;
|
|
39
|
+
post(path: Path, handler: Handler): this;
|
|
40
|
+
put(handler: Handler): this;
|
|
41
|
+
put(path: Path, handler: Handler): this;
|
|
42
|
+
patch(handler: Handler): this;
|
|
43
|
+
patch(path: Path, handler: Handler): this;
|
|
44
|
+
head(handler: Handler): this;
|
|
45
|
+
head(path: Path, handler: Handler): this;
|
|
46
|
+
options(handler: Handler): this;
|
|
47
|
+
options(path: Path, handler: Handler): this;
|
|
45
48
|
use(router: Router): this;
|
|
46
49
|
use(handler: Handler): this;
|
|
47
|
-
use(handler: ErrorHandler): this;
|
|
48
50
|
use(path: Path, router: Router): this;
|
|
49
51
|
use(path: Path, handler: Handler): this;
|
|
50
|
-
|
|
52
|
+
install<Options extends PluginOptions = PluginOptions>(plugin: Plugin<Options>, context: PluginInstallContext<Options> | Options): this;
|
|
53
|
+
uninstall(name: string): void;
|
|
51
54
|
}
|
package/dist/router/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { RouterOptions } from './type';
|
|
2
2
|
export declare function setRouterOptions(id: number, input: Partial<RouterOptions>): void;
|
|
3
3
|
export declare function unsetRouterOptions(id: number): void;
|
|
4
|
-
export declare function findRouterOption<K extends keyof RouterOptions>(key: K,
|
|
4
|
+
export declare function findRouterOption<K extends keyof RouterOptions>(key: K, path?: number[]): RouterOptions[K];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Path
|
|
1
|
+
import type { Path } from '../path';
|
|
2
2
|
import type { EtagFn, EtagInput, TrustProxyFn, TrustProxyInput } from '../utils';
|
|
3
3
|
export type RouterOptions = {
|
|
4
4
|
/**
|
|
@@ -9,18 +9,9 @@ export type RouterOptions = {
|
|
|
9
9
|
*/
|
|
10
10
|
path?: Path;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @default: {end: false}
|
|
15
|
-
*/
|
|
16
|
-
pathMatcher?: PathMatcherOptions;
|
|
17
|
-
/**
|
|
18
|
-
* Milliseconds (ms) until a request handler execution should be canceled.
|
|
19
|
-
*
|
|
20
|
-
* @type number
|
|
21
|
-
* @default undefined
|
|
12
|
+
* Name of the router.
|
|
22
13
|
*/
|
|
23
|
-
|
|
14
|
+
name?: string;
|
|
24
15
|
/**
|
|
25
16
|
* default: 2
|
|
26
17
|
*/
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
/// <reference types="node" />
|
|
4
|
-
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
5
3
|
import type { Readable as NodeReadable } from 'node:stream';
|
|
6
4
|
import type { Readable } from 'readable-stream';
|
|
7
5
|
import type { ReadableStream } from 'stream/web';
|
|
@@ -10,10 +8,3 @@ export type WebReadableStream = globalThis.ReadableStream | ReadableStream;
|
|
|
10
8
|
export type WebResponse = globalThis.Response;
|
|
11
9
|
export type WebRequest = globalThis.Request;
|
|
12
10
|
export type WebBlob = globalThis.Blob;
|
|
13
|
-
export interface Response extends ServerResponse {
|
|
14
|
-
}
|
|
15
|
-
export interface Request extends IncomingMessage {
|
|
16
|
-
}
|
|
17
|
-
export type Next = (err?: Error) => void;
|
|
18
|
-
export type Handler = (req: Request, res: Response, next: Next) => unknown | Promise<unknown>;
|
|
19
|
-
export type ErrorHandler = (err: Error, req: Request, res: Response, next: Next) => unknown | Promise<unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function isInstance(input: unknown,
|
|
1
|
+
export declare function isInstance(input: unknown, sym: symbol): boolean;
|
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,36 @@
|
|
|
50
50
|
},
|
|
51
51
|
"homepage": "https://github.com/routup/routup#readme",
|
|
52
52
|
"dependencies": {
|
|
53
|
+
"@ebec/http": "^2.2.1",
|
|
53
54
|
"buffer": "^6.0.3",
|
|
54
55
|
"mime-explorer": "^1.0.0",
|
|
55
56
|
"negotiator": "^0.6.3",
|
|
56
57
|
"path-to-regexp": "^6.2.1",
|
|
57
58
|
"proxy-addr": "^2.0.7",
|
|
58
59
|
"readable-stream": "^4.4.2",
|
|
59
|
-
"smob": "^1.4.
|
|
60
|
+
"smob": "^1.4.1",
|
|
60
61
|
"uncrypto": "^0.1.3"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
63
64
|
"@rollup/plugin-commonjs": "^25.0.4",
|
|
64
65
|
"@rollup/plugin-node-resolve": "^15.2.1",
|
|
65
|
-
"@swc/core": "^1.3.
|
|
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/readable-stream": "^4.0.
|
|
76
|
-
"@types/supertest": "^2.0.
|
|
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",
|
|
77
78
|
"cross-env": "^7.0.3",
|
|
78
79
|
"jest": "^29.7.0",
|
|
79
|
-
"rimraf": "^5.0.
|
|
80
|
-
"rollup": "^3.29.
|
|
81
|
-
"semantic-release": "^
|
|
80
|
+
"rimraf": "^5.0.5",
|
|
81
|
+
"rollup": "^3.29.4",
|
|
82
|
+
"semantic-release": "^22.0.5",
|
|
82
83
|
"supertest": "^6.3.3",
|
|
83
84
|
"typescript": "5.2.2"
|
|
84
85
|
}
|
package/dist/error.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function createError(input: Error | Record<string, any>): Error;
|
package/dist/route/index.d.ts
DELETED
package/dist/route/module.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { MethodName } from '../constants';
|
|
2
|
-
import type { Dispatcher, DispatcherEvent, DispatcherMeta } from '../dispatcher';
|
|
3
|
-
import { Layer } from '../layer';
|
|
4
|
-
import type { Path, PathMatcherOptions } from '../path';
|
|
5
|
-
import { PathMatcher } from '../path';
|
|
6
|
-
import type { Handler } from '../types';
|
|
7
|
-
import type { RouteOptions } from './type';
|
|
8
|
-
export declare class Route implements Dispatcher {
|
|
9
|
-
readonly '@instanceof': symbol;
|
|
10
|
-
readonly path: Path;
|
|
11
|
-
protected pathMatcher: PathMatcher;
|
|
12
|
-
protected pathMatcherOptions: PathMatcherOptions;
|
|
13
|
-
protected layers: Record<string, Layer[]>;
|
|
14
|
-
constructor(options: RouteOptions);
|
|
15
|
-
matchPath(path: string): boolean;
|
|
16
|
-
matchMethod(method: string): boolean;
|
|
17
|
-
getMethods(): string[];
|
|
18
|
-
dispatch(event: DispatcherEvent, meta: DispatcherMeta): Promise<boolean>;
|
|
19
|
-
register(method: `${MethodName}`, ...handlers: Handler[]): void;
|
|
20
|
-
get(...handlers: Handler[]): void;
|
|
21
|
-
post(...handlers: Handler[]): void;
|
|
22
|
-
put(...handlers: Handler[]): void;
|
|
23
|
-
patch(...handlers: Handler[]): void;
|
|
24
|
-
delete(...handlers: Handler[]): void;
|
|
25
|
-
head(...handlers: Handler[]): void;
|
|
26
|
-
options(...handlers: Handler[]): void;
|
|
27
|
-
private isStrictPath;
|
|
28
|
-
}
|
package/dist/route/type.d.ts
DELETED
package/dist/route/utils.d.ts
DELETED