@kevisual/router 0.0.2 → 0.0.4-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/dist/app.d.ts +3 -0
- package/dist/index.js +21 -1
- package/dist/route.d.ts +2 -0
- package/package.json +12 -12
package/dist/app.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -5869,7 +5869,7 @@ class QueryRouter {
|
|
|
5869
5869
|
if (!message?.path) {
|
|
5870
5870
|
return Promise.resolve({ code: 404, body: 'Not found path' });
|
|
5871
5871
|
}
|
|
5872
|
-
const { path, key, payload = {}, ...query } = message;
|
|
5872
|
+
const { path, key = '', payload = {}, ...query } = message;
|
|
5873
5873
|
ctx = ctx || {};
|
|
5874
5874
|
ctx.query = { ...ctx.query, ...query, ...payload };
|
|
5875
5875
|
ctx.state = {};
|
|
@@ -5900,6 +5900,16 @@ class QueryRouter {
|
|
|
5900
5900
|
return { code, data: body, message };
|
|
5901
5901
|
};
|
|
5902
5902
|
}
|
|
5903
|
+
exportRoutes() {
|
|
5904
|
+
return this.routes.map((r) => {
|
|
5905
|
+
return r;
|
|
5906
|
+
});
|
|
5907
|
+
}
|
|
5908
|
+
importRoutes(routes) {
|
|
5909
|
+
for (let route of routes) {
|
|
5910
|
+
this.add(route);
|
|
5911
|
+
}
|
|
5912
|
+
}
|
|
5903
5913
|
}
|
|
5904
5914
|
/**
|
|
5905
5915
|
* QueryRouterServer
|
|
@@ -6096,6 +6106,7 @@ class Server {
|
|
|
6096
6106
|
res.setHeader('Content-Type', 'application/json; charset=utf-8');
|
|
6097
6107
|
if (cors) {
|
|
6098
6108
|
res.setHeader('Access-Control-Allow-Origin', cors?.origin || '*'); // 允许所有域名的请求访问,可以根据需要设置具体的域名
|
|
6109
|
+
res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization');
|
|
6099
6110
|
res.setHeader('Access-Control-Allow-Methods', 'GET, POST');
|
|
6100
6111
|
if (req.method === 'OPTIONS') {
|
|
6101
6112
|
res.end();
|
|
@@ -6411,6 +6422,15 @@ class App {
|
|
|
6411
6422
|
const router = this.router;
|
|
6412
6423
|
return await router.parse(message, ctx);
|
|
6413
6424
|
}
|
|
6425
|
+
exportRoutes() {
|
|
6426
|
+
return this.router.exportRoutes();
|
|
6427
|
+
}
|
|
6428
|
+
importRoutes(routes) {
|
|
6429
|
+
this.router.importRoutes(routes);
|
|
6430
|
+
}
|
|
6431
|
+
importApp(app) {
|
|
6432
|
+
this.importRoutes(app.exportRoutes());
|
|
6433
|
+
}
|
|
6414
6434
|
}
|
|
6415
6435
|
|
|
6416
6436
|
export { App, Connect, CustomError, QueryConnect, QueryRouter, QueryRouterServer, Result, Route, ZodType as Schema, Server, createSchema, handleServer };
|
package/dist/route.d.ts
CHANGED
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.4-alpha-1",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -16,27 +16,27 @@
|
|
|
16
16
|
"dist"
|
|
17
17
|
],
|
|
18
18
|
"keywords": [],
|
|
19
|
-
"author": "",
|
|
20
|
-
"license": "
|
|
19
|
+
"author": "abearxiong",
|
|
20
|
+
"license": "MIT",
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@rollup/plugin-commonjs": "^
|
|
23
|
-
"@rollup/plugin-node-resolve": "^15.
|
|
24
|
-
"@rollup/plugin-typescript": "^12.1.
|
|
22
|
+
"@rollup/plugin-commonjs": "^28.0.1",
|
|
23
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
24
|
+
"@rollup/plugin-typescript": "^12.1.1",
|
|
25
25
|
"@types/lodash-es": "^4.17.12",
|
|
26
|
-
"@types/node": "^22.
|
|
26
|
+
"@types/node": "^22.7.9",
|
|
27
27
|
"@types/ws": "^8.5.12",
|
|
28
28
|
"lodash-es": "^4.17.21",
|
|
29
29
|
"nanoid": "^5.0.7",
|
|
30
|
-
"rollup": "^4.
|
|
30
|
+
"rollup": "^4.24.0",
|
|
31
31
|
"ts-loader": "^9.5.1",
|
|
32
32
|
"ts-node": "^10.9.2",
|
|
33
|
-
"tslib": "^2.
|
|
34
|
-
"typescript": "^5.6.
|
|
33
|
+
"tslib": "^2.8.0",
|
|
34
|
+
"typescript": "^5.6.3",
|
|
35
35
|
"zod": "^3.23.8"
|
|
36
36
|
},
|
|
37
37
|
"repository": {
|
|
38
38
|
"type": "git",
|
|
39
|
-
"url": "https://github.com/abearxiong/kevisual-router.git"
|
|
39
|
+
"url": "git+https://github.com/abearxiong/kevisual-router.git"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"ws": "^8.18.0"
|
|
@@ -44,4 +44,4 @@
|
|
|
44
44
|
"publishConfig": {
|
|
45
45
|
"access": "public"
|
|
46
46
|
}
|
|
47
|
-
}
|
|
47
|
+
}
|