route list,当时wait的模式添加默认的

This commit is contained in:
2025-11-14 17:43:07 +08:00
parent 87068cd626
commit c0ec625f01
3 changed files with 1683 additions and 8 deletions

View File

@@ -1,7 +1,7 @@
{ {
"$schema": "https://json.schemastore.org/package", "$schema": "https://json.schemastore.org/package",
"name": "@kevisual/router", "name": "@kevisual/router",
"version": "0.0.31", "version": "0.0.32",
"description": "", "description": "",
"type": "module", "type": "module",
"main": "./dist/router.js", "main": "./dist/router.js",
@@ -23,19 +23,19 @@
"devDependencies": { "devDependencies": {
"@kevisual/local-proxy": "^0.0.6", "@kevisual/local-proxy": "^0.0.6",
"@kevisual/query": "^0.0.29", "@kevisual/query": "^0.0.29",
"@rollup/plugin-alias": "^5.1.1", "@rollup/plugin-alias": "^6.0.0",
"@rollup/plugin-commonjs": "28.0.8", "@rollup/plugin-commonjs": "29.0.0",
"@rollup/plugin-node-resolve": "^16.0.3", "@rollup/plugin-node-resolve": "^16.0.3",
"@rollup/plugin-typescript": "^12.3.0", "@rollup/plugin-typescript": "^12.3.0",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/node": "^24.9.1", "@types/node": "^24.10.1",
"@types/send": "^1.2.0", "@types/send": "^1.2.1",
"@types/ws": "^8.18.1", "@types/ws": "^8.18.1",
"@types/xml2js": "^0.4.14", "@types/xml2js": "^0.4.14",
"cookie": "^1.0.2", "cookie": "^1.0.2",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"nanoid": "^5.1.6", "nanoid": "^5.1.6",
"rollup": "^4.52.5", "rollup": "^4.53.2",
"rollup-plugin-dts": "^6.2.3", "rollup-plugin-dts": "^6.2.3",
"ts-loader": "^9.5.4", "ts-loader": "^9.5.4",
"ts-node": "^10.9.2", "ts-node": "^10.9.2",
@@ -51,7 +51,7 @@
}, },
"dependencies": { "dependencies": {
"path-to-regexp": "^8.3.0", "path-to-regexp": "^8.3.0",
"selfsigned": "^3.0.1", "selfsigned": "^4.0.0",
"send": "^1.2.0" "send": "^1.2.0"
}, },
"publishConfig": { "publishConfig": {

1658
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -702,6 +702,19 @@ export class QueryRouter {
hasRoute(path: string, key: string = '') { hasRoute(path: string, key: string = '') {
return this.routes.find((r) => r.path === path && r.key === key); return this.routes.find((r) => r.path === path && r.key === key);
} }
createRouteList(force: boolean = false) {
const hasListRoute = this.hasRoute('route', 'list');
if (!hasListRoute || force) {
const listRoute = new Route('route', 'list', {
description: '列出当前应用下的所有的路由信息',
run: async (ctx: RouteContext) => {
const list = this.getList();
ctx.body = list;
},
});
this.add(listRoute);
}
}
/** /**
* 等待程序运行, 获取到message的数据,就执行 * 等待程序运行, 获取到message的数据,就执行
* *
@@ -710,7 +723,11 @@ export class QueryRouter {
* -- .on * -- .on
* -- .send * -- .send
*/ */
wait(params?: { path?: string; key?: string; payload?: any }, opts?: { emitter?: any, timeout?: number }) { wait(params?: { path?: string; key?: string; payload?: any }, opts?: { emitter?: any, timeout?: number, getList?: boolean }) {
const getList = opts?.getList ?? true;
if (getList) {
this.createRouteList();
}
return listenProcess({ app: this, params, ...opts }); return listenProcess({ app: this, params, ...opts });
} }
} }