@kevisual/router 0.0.24 → 0.0.26-alpha
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/auto.ts +20 -0
- package/dist/router-browser.d.ts +7 -6
- package/dist/router-browser.js +3152 -21606
- package/dist/router.d.ts +4 -4
- package/dist/router.js +3198 -21652
- package/package.json +11 -26
- package/src/route.ts +5 -10
- package/src/sign.ts +1 -1
- package/src/validator/index.ts +4 -1
- package/src/validator/rule.ts +2 -3
- package/dist/router-sign.d.ts +0 -16
- package/dist/router-sign.js +0 -28662
- package/dist/router-simple-lib.d.ts +0 -3
- package/dist/router-simple-lib.js +0 -35
- package/src/io.ts +0 -6
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@kevisual/router",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.26-alpha",
|
|
5
5
|
"description": "",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/router.js",
|
|
@@ -17,38 +17,33 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"dist",
|
|
19
19
|
"src",
|
|
20
|
-
"mod.ts"
|
|
20
|
+
"mod.ts",
|
|
21
|
+
"auto.ts"
|
|
21
22
|
],
|
|
22
23
|
"keywords": [],
|
|
23
24
|
"author": "abearxiong",
|
|
24
25
|
"license": "MIT",
|
|
25
26
|
"devDependencies": {
|
|
26
|
-
"@kevisual/local-proxy": "^0.0.
|
|
27
|
+
"@kevisual/local-proxy": "^0.0.6",
|
|
27
28
|
"@kevisual/query": "^0.0.29",
|
|
28
29
|
"@rollup/plugin-alias": "^5.1.1",
|
|
29
30
|
"@rollup/plugin-commonjs": "^28.0.6",
|
|
30
31
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
31
|
-
"@rollup/plugin-typescript": "^12.1.
|
|
32
|
-
"@types/
|
|
33
|
-
"@types/deno": "^2.3.0",
|
|
34
|
-
"@types/lodash-es": "^4.17.12",
|
|
35
|
-
"@types/node": "^24.0.3",
|
|
32
|
+
"@rollup/plugin-typescript": "^12.1.4",
|
|
33
|
+
"@types/node": "^24.2.1",
|
|
36
34
|
"@types/send": "^0.17.5",
|
|
37
35
|
"@types/ws": "^8.18.1",
|
|
38
36
|
"@types/xml2js": "^0.4.14",
|
|
39
37
|
"cookie": "^1.0.2",
|
|
40
38
|
"deno": "^2.4.3",
|
|
41
|
-
"
|
|
39
|
+
"es-toolkit": "^1.39.8",
|
|
42
40
|
"nanoid": "^5.1.5",
|
|
43
|
-
"rollup": "^4.
|
|
41
|
+
"rollup": "^4.46.2",
|
|
44
42
|
"rollup-plugin-dts": "^6.2.1",
|
|
45
|
-
"
|
|
46
|
-
"ts-node": "^10.9.2",
|
|
47
|
-
"tslib": "^2.8.1",
|
|
48
|
-
"typescript": "^5.8.3",
|
|
43
|
+
"typescript": "^5.9.2",
|
|
49
44
|
"ws": "npm:@kevisual/ws",
|
|
50
45
|
"xml2js": "^0.6.2",
|
|
51
|
-
"zod": "^
|
|
46
|
+
"zod": "^4.0.17"
|
|
52
47
|
},
|
|
53
48
|
"repository": {
|
|
54
49
|
"type": "git",
|
|
@@ -56,7 +51,7 @@
|
|
|
56
51
|
},
|
|
57
52
|
"dependencies": {
|
|
58
53
|
"path-to-regexp": "^8.2.0",
|
|
59
|
-
"selfsigned": "^
|
|
54
|
+
"selfsigned": "^3.0.1",
|
|
60
55
|
"send": "^1.2.0"
|
|
61
56
|
},
|
|
62
57
|
"publishConfig": {
|
|
@@ -73,11 +68,6 @@
|
|
|
73
68
|
"require": "./dist/router-browser.js",
|
|
74
69
|
"types": "./dist/router-browser.d.ts"
|
|
75
70
|
},
|
|
76
|
-
"./sign": {
|
|
77
|
-
"import": "./dist/router-sign.js",
|
|
78
|
-
"require": "./dist/router-sign.js",
|
|
79
|
-
"types": "./dist/router-sign.d.ts"
|
|
80
|
-
},
|
|
81
71
|
"./simple": {
|
|
82
72
|
"import": "./dist/router-simple.js",
|
|
83
73
|
"require": "./dist/router-simple.js",
|
|
@@ -88,11 +78,6 @@
|
|
|
88
78
|
"require": "./dist/router-define.js",
|
|
89
79
|
"types": "./dist/router-define.d.ts"
|
|
90
80
|
},
|
|
91
|
-
"./simple-lib": {
|
|
92
|
-
"import": "./dist/router-simple-lib.js",
|
|
93
|
-
"require": "./dist/router-simple-lib.js",
|
|
94
|
-
"types": "./dist/router-simple-lib.d.ts"
|
|
95
|
-
},
|
|
96
81
|
"./mod.ts": {
|
|
97
82
|
"import": "./mod.ts",
|
|
98
83
|
"require": "./mod.ts",
|
package/src/route.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { nanoid } from 'nanoid';
|
|
|
2
2
|
import { CustomError } from './result/error.ts';
|
|
3
3
|
import { Schema, Rule, createSchema } from './validator/index.ts';
|
|
4
4
|
import { pick } from './utils/pick.ts';
|
|
5
|
-
import { get } from 'lodash-es';
|
|
6
5
|
|
|
7
6
|
export type RouterContextT = { code?: number; [key: string]: any };
|
|
8
7
|
export type RouteContext<T = { code?: number }, S = any> = {
|
|
@@ -87,7 +86,7 @@ export type RouteOpts = {
|
|
|
87
86
|
* }
|
|
88
87
|
*/
|
|
89
88
|
validator?: { [key: string]: Rule };
|
|
90
|
-
schema?: { [key: string]:
|
|
89
|
+
schema?: { [key: string]: any };
|
|
91
90
|
isVerify?: boolean;
|
|
92
91
|
verify?: (ctx?: RouteContext, dev?: boolean) => boolean;
|
|
93
92
|
verifyKey?: (key: string, ctx?: RouteContext, dev?: boolean) => boolean;
|
|
@@ -122,7 +121,7 @@ export class Route<U = { [key: string]: any }> {
|
|
|
122
121
|
middleware?: RouteMiddleware[]; // middleware
|
|
123
122
|
type? = 'route';
|
|
124
123
|
private _validator?: { [key: string]: Rule };
|
|
125
|
-
schema?: { [key: string]:
|
|
124
|
+
schema?: { [key: string]: any };
|
|
126
125
|
data?: any;
|
|
127
126
|
/**
|
|
128
127
|
* 是否需要验证
|
|
@@ -206,12 +205,8 @@ export class Route<U = { [key: string]: any }> {
|
|
|
206
205
|
if (schema[key]) {
|
|
207
206
|
const result = schema[key].safeParse(value);
|
|
208
207
|
if (!result.success) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
if (path) {
|
|
212
|
-
const keyS = `${key}.properties.${path}.message`;
|
|
213
|
-
message = get(validator, keyS, 'Invalid params') as any;
|
|
214
|
-
}
|
|
208
|
+
// TODO:
|
|
209
|
+
const message = 'safe error, TODO:';
|
|
215
210
|
throw new CustomError(500, message);
|
|
216
211
|
}
|
|
217
212
|
}
|
|
@@ -608,7 +603,7 @@ export class QueryRouter {
|
|
|
608
603
|
* @description 这里的上下文是为了在handle函数中使用
|
|
609
604
|
* @param ctx
|
|
610
605
|
*/
|
|
611
|
-
|
|
606
|
+
setContext(ctx: RouteContext) {
|
|
612
607
|
this.context = ctx;
|
|
613
608
|
}
|
|
614
609
|
getList(): RouteInfo[] {
|
package/src/sign.ts
CHANGED
package/src/validator/index.ts
CHANGED
package/src/validator/rule.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { z, ZodError
|
|
2
|
-
export { Schema };
|
|
1
|
+
import { z, ZodError } from 'zod';
|
|
3
2
|
type BaseRule = {
|
|
4
3
|
value?: any;
|
|
5
4
|
required?: boolean;
|
|
@@ -64,7 +63,7 @@ export const schemaFormRule = (rule: Rule): z.ZodType<any, any, any> => {
|
|
|
64
63
|
throw new Error(`Unknown rule type: ${(rule as any)?.type}`);
|
|
65
64
|
}
|
|
66
65
|
};
|
|
67
|
-
export const createSchema = (rule: Rule):
|
|
66
|
+
export const createSchema = (rule: Rule): z.ZodType<any, any, any> => {
|
|
68
67
|
try {
|
|
69
68
|
rule.required = rule.required ?? false;
|
|
70
69
|
if (!rule.required) {
|
package/dist/router-sign.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
type Attributes = {
|
|
2
|
-
name: string;
|
|
3
|
-
value: string;
|
|
4
|
-
};
|
|
5
|
-
type AltNames = {
|
|
6
|
-
type: number;
|
|
7
|
-
value?: string;
|
|
8
|
-
ip?: string;
|
|
9
|
-
};
|
|
10
|
-
declare const createCert: (attrs?: Attributes[], altNames?: AltNames[]) => {
|
|
11
|
-
key: string;
|
|
12
|
-
cert: string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export { createCert };
|
|
16
|
-
export type { AltNames, Attributes };
|