@kevisual/router 0.0.25 → 0.0.26-alpha.1

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/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.25",
4
+ "version": "0.0.26-alpha.1",
5
5
  "description": "",
6
6
  "type": "module",
7
7
  "main": "./dist/router.js",
@@ -24,32 +24,26 @@
24
24
  "author": "abearxiong",
25
25
  "license": "MIT",
26
26
  "devDependencies": {
27
- "@kevisual/local-proxy": "^0.0.3",
27
+ "@kevisual/local-proxy": "^0.0.6",
28
28
  "@kevisual/query": "^0.0.29",
29
29
  "@rollup/plugin-alias": "^5.1.1",
30
30
  "@rollup/plugin-commonjs": "^28.0.6",
31
31
  "@rollup/plugin-node-resolve": "^16.0.1",
32
- "@rollup/plugin-typescript": "^12.1.3",
33
- "@types/bun": "^1.2.10",
34
- "@types/deno": "^2.3.0",
35
- "@types/lodash-es": "^4.17.12",
36
- "@types/node": "^24.0.3",
32
+ "@rollup/plugin-typescript": "^12.1.4",
33
+ "@types/node": "^24.2.1",
37
34
  "@types/send": "^0.17.5",
38
35
  "@types/ws": "^8.18.1",
39
36
  "@types/xml2js": "^0.4.14",
40
37
  "cookie": "^1.0.2",
41
38
  "deno": "^2.4.3",
42
- "lodash-es": "^4.17.21",
39
+ "es-toolkit": "^1.39.8",
43
40
  "nanoid": "^5.1.5",
44
- "rollup": "^4.44.0",
41
+ "rollup": "^4.46.2",
45
42
  "rollup-plugin-dts": "^6.2.1",
46
- "ts-loader": "^9.5.2",
47
- "ts-node": "^10.9.2",
48
- "tslib": "^2.8.1",
49
- "typescript": "^5.8.3",
43
+ "typescript": "^5.9.2",
50
44
  "ws": "npm:@kevisual/ws",
51
45
  "xml2js": "^0.6.2",
52
- "zod": "^3.25.67"
46
+ "zod": "^4.0.17"
53
47
  },
54
48
  "repository": {
55
49
  "type": "git",
@@ -57,7 +51,7 @@
57
51
  },
58
52
  "dependencies": {
59
53
  "path-to-regexp": "^8.2.0",
60
- "selfsigned": "^2.4.1",
54
+ "selfsigned": "^3.0.1",
61
55
  "send": "^1.2.0"
62
56
  },
63
57
  "publishConfig": {
@@ -74,11 +68,6 @@
74
68
  "require": "./dist/router-browser.js",
75
69
  "types": "./dist/router-browser.d.ts"
76
70
  },
77
- "./sign": {
78
- "import": "./dist/router-sign.js",
79
- "require": "./dist/router-sign.js",
80
- "types": "./dist/router-sign.d.ts"
81
- },
82
71
  "./simple": {
83
72
  "import": "./dist/router-simple.js",
84
73
  "require": "./dist/router-simple.js",
@@ -89,11 +78,6 @@
89
78
  "require": "./dist/router-define.js",
90
79
  "types": "./dist/router-define.d.ts"
91
80
  },
92
- "./simple-lib": {
93
- "import": "./dist/router-simple-lib.js",
94
- "require": "./dist/router-simple-lib.js",
95
- "types": "./dist/router-simple-lib.d.ts"
96
- },
97
81
  "./mod.ts": {
98
82
  "import": "./mod.ts",
99
83
  "require": "./mod.ts",
@@ -1,5 +1,5 @@
1
1
  import type { IncomingMessage } from 'http';
2
- import { QueryRouterServer } from '../index.ts';
2
+ import { QueryRouterServer } from '../route.ts';
3
3
  import { getRuntime } from './runtime.ts';
4
4
  import { runFirstCheck } from './listen/run-check.ts';
5
5
  import { cleanup } from './listen/cleanup.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]: Schema<any> };
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]: Schema<any> };
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
- const path = result.error.errors[0]?.path?.join?.('.properties.');
210
- let message = 'Invalid params';
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
- setContext(ctx: RouteContext) {
606
+ setContext(ctx: RouteContext) {
612
607
  this.context = ctx;
613
608
  }
614
609
  getList(): RouteInfo[] {
package/src/sign.ts CHANGED
@@ -30,7 +30,7 @@ export const createCert = (attrs: Attributes[] = [], altNames: AltNames[] = [])
30
30
  );
31
31
 
32
32
  const options = {
33
- days: 365, // 证书有效期(天)
33
+ days: 365 * 99, // 证书有效期(天)
34
34
  extensions: [
35
35
  {
36
36
  name: 'subjectAltName',
@@ -1,3 +1,6 @@
1
+ import { z } from 'zod';
1
2
  export { schemaFormRule, createSchema, createSchemaList } from './rule.ts';
2
3
 
3
- export type { Rule, Schema } from './rule.ts';
4
+ export type { Rule } from './rule.ts';
5
+
6
+ export type Schema = z.ZodType<any, any, any>;
@@ -1,5 +1,4 @@
1
- import { z, ZodError, Schema } from 'zod';
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): Schema => {
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) {
@@ -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 };