@kevisual/router 0.0.6-alpha-5 → 0.0.7

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.
@@ -93,6 +93,9 @@ type RouteOpts = {
93
93
  run?: Run;
94
94
  nextRoute?: NextRoute;
95
95
  description?: string;
96
+ metadata?: {
97
+ [key: string]: any;
98
+ };
96
99
  middleware?: Route[] | string[];
97
100
  type?: 'route' | 'middleware';
98
101
  /**
@@ -112,6 +115,9 @@ type RouteOpts = {
112
115
  isVerify?: boolean;
113
116
  verify?: (ctx?: RouteContext, dev?: boolean) => boolean;
114
117
  verifyKey?: (key: string, ctx?: RouteContext, dev?: boolean) => boolean;
118
+ /**
119
+ * $#$ will be used to split path and key
120
+ */
115
121
  idUsePath?: boolean;
116
122
  isDebug?: boolean;
117
123
  };
@@ -121,13 +127,22 @@ type RouteInfo = Pick<Route, (typeof pickValue)[number]>;
121
127
  declare class Route<U = {
122
128
  [key: string]: any;
123
129
  }> {
130
+ /**
131
+ * 一级路径
132
+ */
124
133
  path?: string;
134
+ /**
135
+ * 二级路径
136
+ */
125
137
  key?: string;
126
138
  id?: string;
127
139
  share?: boolean;
128
140
  run?: Run;
129
141
  nextRoute?: NextRoute;
130
142
  description?: string;
143
+ metadata?: {
144
+ [key: string]: any;
145
+ };
131
146
  middleware?: (Route | string)[];
132
147
  type?: string;
133
148
  private _validator?;
@@ -135,7 +150,13 @@ declare class Route<U = {
135
150
  [key: string]: Schema<any>;
136
151
  };
137
152
  data?: any;
153
+ /**
154
+ * 是否需要验证
155
+ */
138
156
  isVerify?: boolean;
157
+ /**
158
+ * 是否开启debug,开启后会打印错误信息
159
+ */
139
160
  isDebug?: boolean;
140
161
  constructor(path: string, key?: string, opts?: RouteOpts);
141
162
  private createSchema;
@@ -208,7 +229,7 @@ declare class QueryRouter {
208
229
  */
209
230
  remove(route: Route | {
210
231
  path: string;
211
- key: string;
232
+ key?: string;
212
233
  }): void;
213
234
  /**
214
235
  * remove route by id
@@ -292,6 +313,9 @@ declare class QueryRouter {
292
313
  importRoutes(routes: Route[]): void;
293
314
  importRouter(router: QueryRouter): void;
294
315
  throw(code?: number | string, message?: string, tips?: string): void;
316
+ hasRoute(path: string, key?: string): Route<{
317
+ [key: string]: any;
318
+ }>;
295
319
  }
296
320
  type QueryRouterServerOpts = {
297
321
  handleFn?: HandleFn;