@kevisual/router 0.2.2 → 0.2.4
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.js +112 -123
- package/dist/commander.d.ts +11 -14
- package/dist/commander.js +96 -90
- package/dist/opencode.d.ts +11 -14
- package/dist/opencode.js +84 -84
- package/dist/router-browser.d.ts +14 -14
- package/dist/router-browser.js +85 -85
- package/dist/router-define.d.ts +12 -12
- package/dist/router-simple.d.ts +2 -3
- package/dist/router-simple.js +1 -1
- package/dist/router.d.ts +16 -22
- package/dist/router.js +108 -119
- package/dist/ws.d.ts +11 -14
- package/dist/ws.js +23 -34
- package/package.json +3 -4
- package/src/commander.ts +6 -4
package/dist/router-define.d.ts
CHANGED
|
@@ -168,7 +168,7 @@ declare class Route<M extends SimpleObject$1 = SimpleObject$1, U extends SimpleO
|
|
|
168
168
|
description?: string;
|
|
169
169
|
metadata?: M;
|
|
170
170
|
middleware?: RouteMiddleware[];
|
|
171
|
-
type?: string;
|
|
171
|
+
type?: string | undefined;
|
|
172
172
|
/**
|
|
173
173
|
* 是否开启debug,开启后会打印错误信息
|
|
174
174
|
*/
|
|
@@ -266,7 +266,7 @@ declare class QueryRouter<T extends SimpleObject$1 = SimpleObject$1> implements
|
|
|
266
266
|
[key: string]: any;
|
|
267
267
|
}> | {
|
|
268
268
|
code: number;
|
|
269
|
-
body:
|
|
269
|
+
body: null;
|
|
270
270
|
message: string;
|
|
271
271
|
}>;
|
|
272
272
|
/**
|
|
@@ -284,9 +284,9 @@ declare class QueryRouter<T extends SimpleObject$1 = SimpleObject$1> implements
|
|
|
284
284
|
}, ctx?: RouteContext & {
|
|
285
285
|
[key: string]: any;
|
|
286
286
|
}): Promise<{
|
|
287
|
-
code: number;
|
|
288
|
-
data:
|
|
289
|
-
message: string;
|
|
287
|
+
code: number | undefined;
|
|
288
|
+
data: string | number | Object | null | undefined;
|
|
289
|
+
message: string | undefined;
|
|
290
290
|
}>;
|
|
291
291
|
/**
|
|
292
292
|
* Router Run获取数据
|
|
@@ -302,9 +302,9 @@ declare class QueryRouter<T extends SimpleObject$1 = SimpleObject$1> implements
|
|
|
302
302
|
}, ctx?: RouteContext<T> & {
|
|
303
303
|
[key: string]: any;
|
|
304
304
|
}): Promise<{
|
|
305
|
-
code: number;
|
|
306
|
-
data:
|
|
307
|
-
message: string;
|
|
305
|
+
code: number | undefined;
|
|
306
|
+
data: string | number | Object | null | undefined;
|
|
307
|
+
message: string | undefined;
|
|
308
308
|
}>;
|
|
309
309
|
/**
|
|
310
310
|
* 设置上下文
|
|
@@ -339,12 +339,12 @@ declare class QueryRouter<T extends SimpleObject$1 = SimpleObject$1> implements
|
|
|
339
339
|
importRoutes(routes: Route[]): void;
|
|
340
340
|
importRouter(router: QueryRouter): void;
|
|
341
341
|
throw(...args: any[]): void;
|
|
342
|
-
hasRoute(path: string, key?: string): Route<SimpleObject$1, SimpleObject$1
|
|
342
|
+
hasRoute(path: string, key?: string): Route<SimpleObject$1, SimpleObject$1> | undefined;
|
|
343
343
|
findRoute(opts?: {
|
|
344
344
|
path?: string;
|
|
345
345
|
key?: string;
|
|
346
346
|
rid?: string;
|
|
347
|
-
}): Route<SimpleObject$1, SimpleObject$1
|
|
347
|
+
}): Route<SimpleObject$1, SimpleObject$1> | undefined;
|
|
348
348
|
createRouteList(opts?: {
|
|
349
349
|
force?: boolean;
|
|
350
350
|
filter?: (route: Route) => boolean;
|
|
@@ -508,8 +508,8 @@ declare class Chain {
|
|
|
508
508
|
object: RouteOpts;
|
|
509
509
|
app?: QueryRouterServer;
|
|
510
510
|
constructor(object: RouteOpts, opts?: ChainOptions);
|
|
511
|
-
get key(): string;
|
|
512
|
-
get path(): string;
|
|
511
|
+
get key(): string | undefined;
|
|
512
|
+
get path(): string | undefined;
|
|
513
513
|
setDescription(desc: string): this;
|
|
514
514
|
setMeta(metadata: {
|
|
515
515
|
[key: string]: any;
|
package/dist/router-simple.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as node_querystring from 'node:querystring';
|
|
2
1
|
import { Key } from 'path-to-regexp';
|
|
3
2
|
import { IncomingMessage, ServerResponse, Server } from 'node:http';
|
|
4
3
|
import { ListenOptions } from 'node:net';
|
|
@@ -25,7 +24,7 @@ declare class SimpleRouter {
|
|
|
25
24
|
exclude?: string[];
|
|
26
25
|
});
|
|
27
26
|
getBody(req: Req): Promise<Record<string, any>>;
|
|
28
|
-
getSearch(req: Req):
|
|
27
|
+
getSearch(req: Req): any;
|
|
29
28
|
parseSearchValue: (value?: string, opts?: {
|
|
30
29
|
decode?: boolean;
|
|
31
30
|
}) => any;
|
|
@@ -103,7 +102,7 @@ declare class HttpChain {
|
|
|
103
102
|
listenCallBack?: () => void;
|
|
104
103
|
}): () => void;
|
|
105
104
|
getString(value: string | SimpleObject): string;
|
|
106
|
-
sse(value: string | SimpleObject): this;
|
|
105
|
+
sse(value: string | SimpleObject): this | undefined;
|
|
107
106
|
close(): this;
|
|
108
107
|
}
|
|
109
108
|
|
package/dist/router-simple.js
CHANGED
|
@@ -30,7 +30,7 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
30
30
|
};
|
|
31
31
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
32
32
|
|
|
33
|
-
//
|
|
33
|
+
// node_modules/path-to-regexp/dist/index.js
|
|
34
34
|
var require_dist = __commonJS((exports) => {
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.PathError = exports.TokenData = undefined;
|
package/dist/router.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ declare class CustomError extends Error {
|
|
|
22
22
|
static fromCode(code?: number): CustomError;
|
|
23
23
|
static fromErrorData(code?: number, data?: any): CustomError;
|
|
24
24
|
static parseError(e: CustomError): {
|
|
25
|
-
code: number;
|
|
25
|
+
code: number | undefined;
|
|
26
26
|
data: any;
|
|
27
27
|
message: string;
|
|
28
28
|
};
|
|
@@ -36,7 +36,7 @@ declare class CustomError extends Error {
|
|
|
36
36
|
static throw(code?: number | string, opts?: CustomErrorOptions): void;
|
|
37
37
|
static throw(opts?: CustomErrorOptions): void;
|
|
38
38
|
parse(e?: CustomError): {
|
|
39
|
-
code: number;
|
|
39
|
+
code: number | undefined;
|
|
40
40
|
data: any;
|
|
41
41
|
message: string;
|
|
42
42
|
};
|
|
@@ -232,7 +232,7 @@ declare class Route<M extends SimpleObject$1 = SimpleObject$1, U extends SimpleO
|
|
|
232
232
|
description?: string;
|
|
233
233
|
metadata?: M;
|
|
234
234
|
middleware?: RouteMiddleware[];
|
|
235
|
-
type?: string;
|
|
235
|
+
type?: string | undefined;
|
|
236
236
|
/**
|
|
237
237
|
* 是否开启debug,开启后会打印错误信息
|
|
238
238
|
*/
|
|
@@ -347,7 +347,7 @@ declare class QueryRouter<T extends SimpleObject$1 = SimpleObject$1> implements
|
|
|
347
347
|
[key: string]: any;
|
|
348
348
|
}> | {
|
|
349
349
|
code: number;
|
|
350
|
-
body:
|
|
350
|
+
body: null;
|
|
351
351
|
message: string;
|
|
352
352
|
}>;
|
|
353
353
|
/**
|
|
@@ -365,9 +365,9 @@ declare class QueryRouter<T extends SimpleObject$1 = SimpleObject$1> implements
|
|
|
365
365
|
}, ctx?: RouteContext & {
|
|
366
366
|
[key: string]: any;
|
|
367
367
|
}): Promise<{
|
|
368
|
-
code: number;
|
|
369
|
-
data:
|
|
370
|
-
message: string;
|
|
368
|
+
code: number | undefined;
|
|
369
|
+
data: string | number | Object | null | undefined;
|
|
370
|
+
message: string | undefined;
|
|
371
371
|
}>;
|
|
372
372
|
/**
|
|
373
373
|
* Router Run获取数据
|
|
@@ -383,9 +383,9 @@ declare class QueryRouter<T extends SimpleObject$1 = SimpleObject$1> implements
|
|
|
383
383
|
}, ctx?: RouteContext<T> & {
|
|
384
384
|
[key: string]: any;
|
|
385
385
|
}): Promise<{
|
|
386
|
-
code: number;
|
|
387
|
-
data:
|
|
388
|
-
message: string;
|
|
386
|
+
code: number | undefined;
|
|
387
|
+
data: string | number | Object | null | undefined;
|
|
388
|
+
message: string | undefined;
|
|
389
389
|
}>;
|
|
390
390
|
/**
|
|
391
391
|
* 设置上下文
|
|
@@ -420,12 +420,12 @@ declare class QueryRouter<T extends SimpleObject$1 = SimpleObject$1> implements
|
|
|
420
420
|
importRoutes(routes: Route[]): void;
|
|
421
421
|
importRouter(router: QueryRouter): void;
|
|
422
422
|
throw(...args: any[]): void;
|
|
423
|
-
hasRoute(path: string, key?: string): Route<SimpleObject$1, SimpleObject$1
|
|
423
|
+
hasRoute(path: string, key?: string): Route<SimpleObject$1, SimpleObject$1> | undefined;
|
|
424
424
|
findRoute(opts?: {
|
|
425
425
|
path?: string;
|
|
426
426
|
key?: string;
|
|
427
427
|
rid?: string;
|
|
428
|
-
}): Route<SimpleObject$1, SimpleObject$1
|
|
428
|
+
}): Route<SimpleObject$1, SimpleObject$1> | undefined;
|
|
429
429
|
createRouteList(opts?: {
|
|
430
430
|
force?: boolean;
|
|
431
431
|
filter?: (route: Route) => boolean;
|
|
@@ -628,8 +628,8 @@ declare class Chain {
|
|
|
628
628
|
object: RouteOpts;
|
|
629
629
|
app?: QueryRouterServer;
|
|
630
630
|
constructor(object: RouteOpts, opts?: ChainOptions);
|
|
631
|
-
get key(): string;
|
|
632
|
-
get path(): string;
|
|
631
|
+
get key(): string | undefined;
|
|
632
|
+
get path(): string | undefined;
|
|
633
633
|
setDescription(desc: string): this;
|
|
634
634
|
setMeta(metadata: {
|
|
635
635
|
[key: string]: any;
|
|
@@ -1031,10 +1031,7 @@ declare class ServerNode extends ServerBase implements ServerType {
|
|
|
1031
1031
|
* @param res
|
|
1032
1032
|
* @returns
|
|
1033
1033
|
*/
|
|
1034
|
-
declare const handleServer: (req: IncomingMessage, res: ServerResponse) => Promise<
|
|
1035
|
-
cookies: Record<string, string>;
|
|
1036
|
-
token: string;
|
|
1037
|
-
}>;
|
|
1034
|
+
declare const handleServer: (req: IncomingMessage, res: ServerResponse) => Promise<any>;
|
|
1038
1035
|
|
|
1039
1036
|
type RouterHandle = (msg: {
|
|
1040
1037
|
path: string;
|
|
@@ -1076,10 +1073,7 @@ declare class App<U = {}> extends QueryRouterServer<AppRouteContext<U>> {
|
|
|
1076
1073
|
listen(handle: any, backlog?: number, listeningListener?: () => void): void;
|
|
1077
1074
|
listen(handle: any, listeningListener?: () => void): void;
|
|
1078
1075
|
Route: typeof Route;
|
|
1079
|
-
static handleRequest(req: IncomingMessage$1, res: ServerResponse$1): Promise<
|
|
1080
|
-
cookies: Record<string, string>;
|
|
1081
|
-
token: string;
|
|
1082
|
-
}>;
|
|
1076
|
+
static handleRequest(req: IncomingMessage$1, res: ServerResponse$1): Promise<any>;
|
|
1083
1077
|
onServerRequest(fn: (req: IncomingMessage$1, res: ServerResponse$1) => void): void;
|
|
1084
1078
|
}
|
|
1085
1079
|
|