@kevisual/router 0.0.39 → 0.0.40
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/router-browser.d.ts +11 -15
- package/dist/router-browser.js +687 -19
- package/dist/router-simple.d.ts +2 -2
- package/dist/router.d.ts +107 -17
- package/dist/router.js +928 -383
- package/package.json +6 -8
- package/src/result/error.ts +2 -5
- package/src/server/cookie.ts +543 -0
- package/src/server/server.ts +1 -1
package/dist/router-browser.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import * as
|
|
2
|
+
import * as node_querystring from 'node:querystring';
|
|
3
3
|
import { IncomingMessage } from 'node:http';
|
|
4
4
|
import { RouteOpts as RouteOpts$1, QueryRouterServer as QueryRouterServer$1, RouteMiddleware as RouteMiddleware$1, Run as Run$1 } from '@kevisual/router';
|
|
5
5
|
import { Query, DataOpts, Result } from '@kevisual/query/query';
|
|
@@ -82,16 +82,14 @@ type RouteMiddleware = {
|
|
|
82
82
|
key?: string;
|
|
83
83
|
id?: string;
|
|
84
84
|
} | string;
|
|
85
|
-
type RouteOpts<
|
|
85
|
+
type RouteOpts<U = {}, T = SimpleObject$1> = {
|
|
86
86
|
path?: string;
|
|
87
87
|
key?: string;
|
|
88
88
|
id?: string;
|
|
89
|
-
run?: Run<
|
|
89
|
+
run?: Run<U>;
|
|
90
90
|
nextRoute?: NextRoute;
|
|
91
91
|
description?: string;
|
|
92
|
-
metadata?:
|
|
93
|
-
[key: string]: any;
|
|
94
|
-
};
|
|
92
|
+
metadata?: T;
|
|
95
93
|
middleware?: RouteMiddleware[];
|
|
96
94
|
type?: 'route' | 'middleware';
|
|
97
95
|
/**
|
|
@@ -109,7 +107,7 @@ declare const pickValue: readonly ["path", "key", "id", "description", "type", "
|
|
|
109
107
|
type RouteInfo = Pick<Route, (typeof pickValue)[number]>;
|
|
110
108
|
declare class Route<U = {
|
|
111
109
|
[key: string]: any;
|
|
112
|
-
}> {
|
|
110
|
+
}, T extends SimpleObject$1 = SimpleObject$1> {
|
|
113
111
|
/**
|
|
114
112
|
* 一级路径
|
|
115
113
|
*/
|
|
@@ -122,9 +120,7 @@ declare class Route<U = {
|
|
|
122
120
|
run?: Run;
|
|
123
121
|
nextRoute?: NextRoute;
|
|
124
122
|
description?: string;
|
|
125
|
-
metadata?:
|
|
126
|
-
[key: string]: any;
|
|
127
|
-
};
|
|
123
|
+
metadata?: T;
|
|
128
124
|
middleware?: RouteMiddleware[];
|
|
129
125
|
type?: string;
|
|
130
126
|
data?: any;
|
|
@@ -252,7 +248,7 @@ declare class QueryRouter {
|
|
|
252
248
|
* @param ctx
|
|
253
249
|
*/
|
|
254
250
|
setContext(ctx: RouteContext): void;
|
|
255
|
-
getList(): RouteInfo[];
|
|
251
|
+
getList(filter?: (route: Route) => boolean): RouteInfo[];
|
|
256
252
|
/**
|
|
257
253
|
* 获取handle函数, 这里会去执行parse函数
|
|
258
254
|
*/
|
|
@@ -277,13 +273,13 @@ declare class QueryRouter {
|
|
|
277
273
|
}>;
|
|
278
274
|
exportRoutes(): Route<{
|
|
279
275
|
[key: string]: any;
|
|
280
|
-
}>[];
|
|
276
|
+
}, SimpleObject$1>[];
|
|
281
277
|
importRoutes(routes: Route[]): void;
|
|
282
278
|
importRouter(router: QueryRouter): void;
|
|
283
279
|
throw(code?: number | string, message?: string, tips?: string): void;
|
|
284
280
|
hasRoute(path: string, key?: string): Route<{
|
|
285
281
|
[key: string]: any;
|
|
286
|
-
}>;
|
|
282
|
+
}, SimpleObject$1>;
|
|
287
283
|
createRouteList(force?: boolean): void;
|
|
288
284
|
/**
|
|
289
285
|
* 等待程序运行, 获取到message的数据,就执行
|
|
@@ -410,7 +406,7 @@ declare class CustomError extends Error {
|
|
|
410
406
|
* @param err
|
|
411
407
|
* @returns
|
|
412
408
|
*/
|
|
413
|
-
static isError(
|
|
409
|
+
static isError(error: unknown): error is CustomError;
|
|
414
410
|
parse(e?: CustomError): {
|
|
415
411
|
code: number;
|
|
416
412
|
data: any;
|
|
@@ -420,7 +416,7 @@ declare class CustomError extends Error {
|
|
|
420
416
|
}
|
|
421
417
|
|
|
422
418
|
declare const parseBody: <T = Record<string, any>>(req: IncomingMessage) => Promise<T>;
|
|
423
|
-
declare const parseSearch: (req: IncomingMessage) =>
|
|
419
|
+
declare const parseSearch: (req: IncomingMessage) => node_querystring.ParsedUrlQuery;
|
|
424
420
|
/**
|
|
425
421
|
* 把url当个key 的 value 的字符串转成json
|
|
426
422
|
* @param value
|