@kevisual/router 0.0.2

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/dist/app.d.ts ADDED
@@ -0,0 +1,60 @@
1
+ import { QueryRouter, Route, RouteContext, RouteOpts } from './route.ts';
2
+ import { Server, Cors } from './server/server.ts';
3
+ import { WsServer } from './server/ws-server.ts';
4
+ type RouterHandle = (msg: {
5
+ path: string;
6
+ [key: string]: any;
7
+ }) => {
8
+ code: string;
9
+ data?: any;
10
+ message?: string;
11
+ [key: string]: any;
12
+ };
13
+ type AppOptions<T = {}> = {
14
+ router?: QueryRouter;
15
+ server?: Server;
16
+ /** handle msg 关联 */
17
+ routerHandle?: RouterHandle;
18
+ routerContext?: RouteContext<T>;
19
+ serverOptions?: {
20
+ path?: string;
21
+ cors?: Cors;
22
+ handle?: any;
23
+ };
24
+ io?: boolean;
25
+ ioOpts?: {
26
+ routerHandle?: RouterHandle;
27
+ routerContext?: RouteContext<T>;
28
+ path?: string;
29
+ };
30
+ };
31
+ export declare class App<T = {}> {
32
+ router: QueryRouter;
33
+ server: Server;
34
+ io: WsServer;
35
+ constructor(opts?: AppOptions<T>);
36
+ listen(port: number, hostname?: string, backlog?: number, listeningListener?: () => void): void;
37
+ listen(port: number, hostname?: string, listeningListener?: () => void): void;
38
+ listen(port: number, backlog?: number, listeningListener?: () => void): void;
39
+ listen(port: number, listeningListener?: () => void): void;
40
+ listen(path: string, backlog?: number, listeningListener?: () => void): void;
41
+ listen(path: string, listeningListener?: () => void): void;
42
+ listen(handle: any, backlog?: number, listeningListener?: () => void): void;
43
+ listen(handle: any, listeningListener?: () => void): void;
44
+ use(path: string, fn: (ctx: any) => any, opts?: RouteOpts): void;
45
+ addRoute(route: Route): void;
46
+ add: (route: Route) => void;
47
+ Route: typeof Route;
48
+ route(opts: RouteOpts): Route;
49
+ route(path: string, key?: string): Route;
50
+ route(path: string, opts?: RouteOpts): Route;
51
+ route(path: string, key?: string, opts?: RouteOpts): Route;
52
+ call(message: {
53
+ path: string;
54
+ key: string;
55
+ payload?: any;
56
+ }, ctx?: RouteContext & {
57
+ [key: string]: any;
58
+ }): Promise<any>;
59
+ }
60
+ export {};
@@ -0,0 +1,30 @@
1
+ import { RouteContext } from './route.ts';
2
+ export declare class Connect {
3
+ path: string;
4
+ key?: string;
5
+ _fn?: (ctx?: RouteContext) => Promise<RouteContext>;
6
+ description?: string;
7
+ connects: {
8
+ path: string;
9
+ key?: string;
10
+ }[];
11
+ share: boolean;
12
+ constructor(path: string);
13
+ use(path: string): void;
14
+ useList(paths: string[]): void;
15
+ useConnect(connect: Connect): void;
16
+ useConnectList(connects: Connect[]): void;
17
+ getPathList(): string[];
18
+ set fn(fn: (ctx?: RouteContext) => Promise<RouteContext>);
19
+ get fn(): (ctx?: RouteContext) => Promise<RouteContext>;
20
+ }
21
+ export declare class QueryConnect {
22
+ connects: Connect[];
23
+ constructor();
24
+ add(connect: Connect): void;
25
+ remove(connect: Connect): void;
26
+ getList(): {
27
+ path: string;
28
+ key: string;
29
+ }[];
30
+ }
@@ -0,0 +1,15 @@
1
+ export { Route, QueryRouter, QueryRouterServer } from './route.ts';
2
+ export { Connect, QueryConnect } from './connect.ts';
3
+ export type { RouteContext, RouteOpts } from './route.ts';
4
+ export type { Run } from './route.ts';
5
+ export { Server, handleServer } from './server/index.ts';
6
+ /**
7
+ * 自定义错误
8
+ */
9
+ export { CustomError } from './result/error.ts';
10
+ /**
11
+ * 返回结果
12
+ */
13
+ export { Result } from './result/index.ts';
14
+ export { Rule, Schema, createSchema } from './validator/index.ts';
15
+ export { App } from './app.ts';