@kevisual/router 0.0.32 → 0.0.33

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.
@@ -365,6 +365,7 @@ declare class QueryRouter {
365
365
  hasRoute(path: string, key?: string): Route<{
366
366
  [key: string]: any;
367
367
  }>;
368
+ createRouteList(force?: boolean): void;
368
369
  /**
369
370
  * 等待程序运行, 获取到message的数据,就执行
370
371
  *
@@ -380,6 +381,7 @@ declare class QueryRouter {
380
381
  }, opts?: {
381
382
  emitter?: any;
382
383
  timeout?: number;
384
+ getList?: boolean;
383
385
  }): Promise<void>;
384
386
  }
385
387
  type QueryRouterServerOpts = {
@@ -5394,6 +5394,19 @@ class QueryRouter {
5394
5394
  hasRoute(path, key = '') {
5395
5395
  return this.routes.find((r) => r.path === path && r.key === key);
5396
5396
  }
5397
+ createRouteList(force = false) {
5398
+ const hasListRoute = this.hasRoute('route', 'list');
5399
+ if (!hasListRoute || force) {
5400
+ const listRoute = new Route('route', 'list', {
5401
+ description: '列出当前应用下的所有的路由信息',
5402
+ run: async (ctx) => {
5403
+ const list = this.getList();
5404
+ ctx.body = list;
5405
+ },
5406
+ });
5407
+ this.add(listRoute);
5408
+ }
5409
+ }
5397
5410
  /**
5398
5411
  * 等待程序运行, 获取到message的数据,就执行
5399
5412
  *
@@ -5403,6 +5416,10 @@ class QueryRouter {
5403
5416
  * -- .send
5404
5417
  */
5405
5418
  wait(params, opts) {
5419
+ const getList = opts?.getList ?? true;
5420
+ if (getList) {
5421
+ this.createRouteList();
5422
+ }
5406
5423
  return listenProcess({ app: this, params, ...opts });
5407
5424
  }
5408
5425
  }
package/dist/router.d.ts CHANGED
@@ -369,6 +369,7 @@ declare class QueryRouter {
369
369
  hasRoute(path: string, key?: string): Route<{
370
370
  [key: string]: any;
371
371
  }>;
372
+ createRouteList(force?: boolean): void;
372
373
  /**
373
374
  * 等待程序运行, 获取到message的数据,就执行
374
375
  *
@@ -384,6 +385,7 @@ declare class QueryRouter {
384
385
  }, opts?: {
385
386
  emitter?: any;
386
387
  timeout?: number;
388
+ getList?: boolean;
387
389
  }): Promise<void>;
388
390
  }
389
391
  type QueryRouterServerOpts = {
package/dist/router.js CHANGED
@@ -5416,6 +5416,19 @@ class QueryRouter {
5416
5416
  hasRoute(path, key = '') {
5417
5417
  return this.routes.find((r) => r.path === path && r.key === key);
5418
5418
  }
5419
+ createRouteList(force = false) {
5420
+ const hasListRoute = this.hasRoute('route', 'list');
5421
+ if (!hasListRoute || force) {
5422
+ const listRoute = new Route('route', 'list', {
5423
+ description: '列出当前应用下的所有的路由信息',
5424
+ run: async (ctx) => {
5425
+ const list = this.getList();
5426
+ ctx.body = list;
5427
+ },
5428
+ });
5429
+ this.add(listRoute);
5430
+ }
5431
+ }
5419
5432
  /**
5420
5433
  * 等待程序运行, 获取到message的数据,就执行
5421
5434
  *
@@ -5425,6 +5438,10 @@ class QueryRouter {
5425
5438
  * -- .send
5426
5439
  */
5427
5440
  wait(params, opts) {
5441
+ const getList = opts?.getList ?? true;
5442
+ if (getList) {
5443
+ this.createRouteList();
5444
+ }
5428
5445
  return listenProcess({ app: this, params, ...opts });
5429
5446
  }
5430
5447
  }
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.32",
4
+ "version": "0.0.33",
5
5
  "description": "",
6
6
  "type": "module",
7
7
  "main": "./dist/router.js",