@kevisual/router 0.2.4 → 0.2.6

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.
@@ -171,7 +171,7 @@ declare class Route<M extends SimpleObject = SimpleObject, U extends SimpleObjec
171
171
  description?: string;
172
172
  metadata?: M;
173
173
  middleware?: RouteMiddleware[];
174
- type?: string | undefined;
174
+ type?: string;
175
175
  /**
176
176
  * 是否开启debug,开启后会打印错误信息
177
177
  */
@@ -247,6 +247,7 @@ declare class QueryRouter<T extends SimpleObject = SimpleObject> implements thro
247
247
  path: string;
248
248
  key?: string;
249
249
  payload?: any;
250
+ args?: any;
250
251
  }, ctx?: RouteContext<T> & {
251
252
  [key: string]: any;
252
253
  }): Promise<RouteContext<T, {}, {
@@ -263,13 +264,14 @@ declare class QueryRouter<T extends SimpleObject = SimpleObject> implements thro
263
264
  path?: string;
264
265
  key?: string;
265
266
  payload?: any;
267
+ args?: any;
266
268
  }, ctx?: RouteContext<T> & {
267
269
  [key: string]: any;
268
270
  }): Promise<RouteContext<T, {}, {
269
271
  [key: string]: any;
270
272
  }> | {
271
273
  code: number;
272
- body: null;
274
+ body: any;
273
275
  message: string;
274
276
  }>;
275
277
  /**
@@ -284,12 +286,13 @@ declare class QueryRouter<T extends SimpleObject = SimpleObject> implements thro
284
286
  path: string;
285
287
  key?: string;
286
288
  payload?: any;
289
+ args?: any;
287
290
  }, ctx?: RouteContext & {
288
291
  [key: string]: any;
289
292
  }): Promise<{
290
- code: number | undefined;
291
- data: string | number | Object | null | undefined;
292
- message: string | undefined;
293
+ code: number;
294
+ data: any;
295
+ message: string;
293
296
  }>;
294
297
  /**
295
298
  * Router Run获取数据
@@ -302,12 +305,13 @@ declare class QueryRouter<T extends SimpleObject = SimpleObject> implements thro
302
305
  path?: string;
303
306
  key?: string;
304
307
  payload?: any;
308
+ args?: any;
305
309
  }, ctx?: RouteContext<T> & {
306
310
  [key: string]: any;
307
311
  }): Promise<{
308
- code: number | undefined;
309
- data: string | number | Object | null | undefined;
310
- message: string | undefined;
312
+ code: number;
313
+ data: any;
314
+ message: string;
311
315
  }>;
312
316
  /**
313
317
  * 设置上下文
@@ -342,12 +346,12 @@ declare class QueryRouter<T extends SimpleObject = SimpleObject> implements thro
342
346
  importRoutes(routes: Route[]): void;
343
347
  importRouter(router: QueryRouter): void;
344
348
  throw(...args: any[]): void;
345
- hasRoute(path: string, key?: string): Route<SimpleObject, SimpleObject> | undefined;
349
+ hasRoute(path: string, key?: string): Route<SimpleObject, SimpleObject>;
346
350
  findRoute(opts?: {
347
351
  path?: string;
348
352
  key?: string;
349
353
  rid?: string;
350
- }): Route<SimpleObject, SimpleObject> | undefined;
354
+ }): Route<SimpleObject, SimpleObject>;
351
355
  createRouteList(opts?: {
352
356
  force?: boolean;
353
357
  filter?: (route: Route) => boolean;
@@ -441,6 +445,7 @@ declare class QueryRouterServer<C extends SimpleObject = SimpleObject> extends Q
441
445
  path?: string;
442
446
  key?: string;
443
447
  payload?: any;
448
+ args?: any;
444
449
  token?: string;
445
450
  data?: any;
446
451
  }, ctx?: Partial<RouteContext<C>>): Promise<any>;
@@ -456,7 +461,9 @@ declare class QueryRouterServer<C extends SimpleObject = SimpleObject> extends Q
456
461
  * 创建认证相关的中间件,默认是 auth, auth-admin, auth-can 三个中间件
457
462
  * @param fun 认证函数,接收 RouteContext 和认证类型
458
463
  */
459
- createAuth(fun: (ctx: RouteContext<C>, type?: 'auth' | 'auth-admin' | 'auth-can') => any): Promise<void>;
464
+ createAuth(fun?: (ctx: RouteContext<C>, type?: 'auth' | 'auth-admin' | 'auth-can') => any, opts?: {
465
+ overwrite?: boolean;
466
+ }): Promise<void>;
460
467
  }
461
468
  /** JSON Schema 基本类型映射到 TypeScript 类型 */
462
469
  type JsonSchemaTypeToTS<T> = T extends {
@@ -791,7 +798,10 @@ declare class App<U = {}> extends QueryRouterServer<AppRouteContext<U>> {
791
798
  listen(handle: any, backlog?: number, listeningListener?: () => void): void;
792
799
  listen(handle: any, listeningListener?: () => void): void;
793
800
  Route: typeof Route;
794
- static handleRequest(req: IncomingMessage$1, res: ServerResponse$1): Promise<any>;
801
+ static handleRequest(req: IncomingMessage$1, res: ServerResponse$1): Promise<{
802
+ cookies: Record<string, string>;
803
+ token: string;
804
+ }>;
795
805
  onServerRequest(fn: (req: IncomingMessage$1, res: ServerResponse$1) => void): void;
796
806
  }
797
807