@kevisual/router 0.2.4 → 0.2.6
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 +13 -12
- package/dist/app.js +131 -119
- package/dist/commander.d.ts +31 -14
- package/dist/commander.js +134 -122
- package/dist/opencode.d.ts +22 -12
- package/dist/opencode.js +84 -84
- package/dist/router-browser.d.ts +24 -33
- package/dist/router-browser.js +93 -93
- package/dist/router-define.d.ts +20 -13
- package/dist/router-simple.d.ts +3 -2
- package/dist/router-simple.js +193 -177
- package/dist/router.d.ts +32 -35
- package/dist/router.js +127 -116
- package/dist/ws.d.ts +22 -12
- package/dist/ws.js +34 -23
- package/package.json +7 -7
- package/src/auto/listen/server-time.ts +1 -1
- package/src/browser.ts +0 -2
- package/src/commander.ts +49 -37
- package/src/index.ts +0 -2
- package/src/route.ts +12 -11
- package/src/router-simple.ts +1 -1
- package/src/test/api.d.ts +72 -0
- package/src/test/api.js +1 -0
- package/src/test/cli.ts +0 -0
- package/src/test/mini.ts +11 -3
- package/src/test/route-ts.ts +1 -1
- package/src/test/run-schema.ts +2 -1
- package/src/test/static.ts +1 -1
- package/src/test/ws.ts +1 -0
- package/src/utils/listen-process.ts +1 -1
- package/src/test/define.ts +0 -14
- package/src/test/listen-ip.ts +0 -18
- package/src/test/schema.ts +0 -14
package/dist/commander.d.ts
CHANGED
|
@@ -171,7 +171,7 @@ declare class Route<M extends SimpleObject = SimpleObject, U extends SimpleObjec
|
|
|
171
171
|
description?: string;
|
|
172
172
|
metadata?: M;
|
|
173
173
|
middleware?: RouteMiddleware[];
|
|
174
|
-
type?: string
|
|
174
|
+
type?: string;
|
|
175
175
|
/**
|
|
176
176
|
* 是否开启debug,开启后会打印错误信息
|
|
177
177
|
*/
|
|
@@ -247,6 +247,7 @@ declare class QueryRouter<T extends SimpleObject = SimpleObject> implements thro
|
|
|
247
247
|
path: string;
|
|
248
248
|
key?: string;
|
|
249
249
|
payload?: any;
|
|
250
|
+
args?: any;
|
|
250
251
|
}, ctx?: RouteContext<T> & {
|
|
251
252
|
[key: string]: any;
|
|
252
253
|
}): Promise<RouteContext<T, {}, {
|
|
@@ -263,13 +264,14 @@ declare class QueryRouter<T extends SimpleObject = SimpleObject> implements thro
|
|
|
263
264
|
path?: string;
|
|
264
265
|
key?: string;
|
|
265
266
|
payload?: any;
|
|
267
|
+
args?: any;
|
|
266
268
|
}, ctx?: RouteContext<T> & {
|
|
267
269
|
[key: string]: any;
|
|
268
270
|
}): Promise<RouteContext<T, {}, {
|
|
269
271
|
[key: string]: any;
|
|
270
272
|
}> | {
|
|
271
273
|
code: number;
|
|
272
|
-
body:
|
|
274
|
+
body: any;
|
|
273
275
|
message: string;
|
|
274
276
|
}>;
|
|
275
277
|
/**
|
|
@@ -284,12 +286,13 @@ declare class QueryRouter<T extends SimpleObject = SimpleObject> implements thro
|
|
|
284
286
|
path: string;
|
|
285
287
|
key?: string;
|
|
286
288
|
payload?: any;
|
|
289
|
+
args?: any;
|
|
287
290
|
}, ctx?: RouteContext & {
|
|
288
291
|
[key: string]: any;
|
|
289
292
|
}): Promise<{
|
|
290
|
-
code: number
|
|
291
|
-
data:
|
|
292
|
-
message: string
|
|
293
|
+
code: number;
|
|
294
|
+
data: any;
|
|
295
|
+
message: string;
|
|
293
296
|
}>;
|
|
294
297
|
/**
|
|
295
298
|
* Router Run获取数据
|
|
@@ -302,12 +305,13 @@ declare class QueryRouter<T extends SimpleObject = SimpleObject> implements thro
|
|
|
302
305
|
path?: string;
|
|
303
306
|
key?: string;
|
|
304
307
|
payload?: any;
|
|
308
|
+
args?: any;
|
|
305
309
|
}, ctx?: RouteContext<T> & {
|
|
306
310
|
[key: string]: any;
|
|
307
311
|
}): Promise<{
|
|
308
|
-
code: number
|
|
309
|
-
data:
|
|
310
|
-
message: string
|
|
312
|
+
code: number;
|
|
313
|
+
data: any;
|
|
314
|
+
message: string;
|
|
311
315
|
}>;
|
|
312
316
|
/**
|
|
313
317
|
* 设置上下文
|
|
@@ -342,12 +346,12 @@ declare class QueryRouter<T extends SimpleObject = SimpleObject> implements thro
|
|
|
342
346
|
importRoutes(routes: Route[]): void;
|
|
343
347
|
importRouter(router: QueryRouter): void;
|
|
344
348
|
throw(...args: any[]): void;
|
|
345
|
-
hasRoute(path: string, key?: string): Route<SimpleObject, SimpleObject
|
|
349
|
+
hasRoute(path: string, key?: string): Route<SimpleObject, SimpleObject>;
|
|
346
350
|
findRoute(opts?: {
|
|
347
351
|
path?: string;
|
|
348
352
|
key?: string;
|
|
349
353
|
rid?: string;
|
|
350
|
-
}): Route<SimpleObject, SimpleObject
|
|
354
|
+
}): Route<SimpleObject, SimpleObject>;
|
|
351
355
|
createRouteList(opts?: {
|
|
352
356
|
force?: boolean;
|
|
353
357
|
filter?: (route: Route) => boolean;
|
|
@@ -441,6 +445,7 @@ declare class QueryRouterServer<C extends SimpleObject = SimpleObject> extends Q
|
|
|
441
445
|
path?: string;
|
|
442
446
|
key?: string;
|
|
443
447
|
payload?: any;
|
|
448
|
+
args?: any;
|
|
444
449
|
token?: string;
|
|
445
450
|
data?: any;
|
|
446
451
|
}, ctx?: Partial<RouteContext<C>>): Promise<any>;
|
|
@@ -456,7 +461,9 @@ declare class QueryRouterServer<C extends SimpleObject = SimpleObject> extends Q
|
|
|
456
461
|
* 创建认证相关的中间件,默认是 auth, auth-admin, auth-can 三个中间件
|
|
457
462
|
* @param fun 认证函数,接收 RouteContext 和认证类型
|
|
458
463
|
*/
|
|
459
|
-
createAuth(fun
|
|
464
|
+
createAuth(fun?: (ctx: RouteContext<C>, type?: 'auth' | 'auth-admin' | 'auth-can') => any, opts?: {
|
|
465
|
+
overwrite?: boolean;
|
|
466
|
+
}): Promise<void>;
|
|
460
467
|
}
|
|
461
468
|
/** JSON Schema 基本类型映射到 TypeScript 类型 */
|
|
462
469
|
type JsonSchemaTypeToTS<T> = T extends {
|
|
@@ -791,17 +798,25 @@ declare class App<U = {}> extends QueryRouterServer<AppRouteContext<U>> {
|
|
|
791
798
|
listen(handle: any, backlog?: number, listeningListener?: () => void): void;
|
|
792
799
|
listen(handle: any, listeningListener?: () => void): void;
|
|
793
800
|
Route: typeof Route;
|
|
794
|
-
static handleRequest(req: IncomingMessage$1, res: ServerResponse$1): Promise<
|
|
801
|
+
static handleRequest(req: IncomingMessage$1, res: ServerResponse$1): Promise<{
|
|
802
|
+
cookies: Record<string, string>;
|
|
803
|
+
token: string;
|
|
804
|
+
}>;
|
|
795
805
|
onServerRequest(fn: (req: IncomingMessage$1, res: ServerResponse$1) => void): void;
|
|
796
806
|
}
|
|
797
807
|
|
|
798
808
|
declare const groupByPath: (routes: App["routes"]) => Record<string, Route<SimpleObject, SimpleObject>[]>;
|
|
799
809
|
declare const parseArgs: (args: string) => any;
|
|
800
810
|
declare const parseDescription: (route: App["routes"][number]) => string;
|
|
801
|
-
declare const
|
|
811
|
+
declare const createCommandList: (opts: {
|
|
802
812
|
app: any;
|
|
803
813
|
program: Command;
|
|
804
814
|
}) => void;
|
|
815
|
+
declare const createCommand: (command: Command, opts: {
|
|
816
|
+
description?: string;
|
|
817
|
+
app: App;
|
|
818
|
+
route: any;
|
|
819
|
+
}) => void;
|
|
805
820
|
declare const parse: (opts: {
|
|
806
821
|
app: any;
|
|
807
822
|
description?: string;
|
|
@@ -812,8 +827,10 @@ declare const parse: (opts: {
|
|
|
812
827
|
token?: string;
|
|
813
828
|
username?: string;
|
|
814
829
|
id?: string;
|
|
830
|
+
/** https://kevisual.cn/ws/proxy */
|
|
831
|
+
url?: string;
|
|
815
832
|
};
|
|
816
833
|
exitOnEnd?: boolean;
|
|
817
834
|
}) => Promise<void>;
|
|
818
835
|
|
|
819
|
-
export { createCommand, groupByPath, parse, parseArgs, parseDescription };
|
|
836
|
+
export { createCommand, createCommandList, groupByPath, parse, parseArgs, parseDescription };
|