@kevisual/router 0.0.57 → 0.0.58

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.
@@ -310,6 +310,11 @@ declare class QueryRouter {
310
310
  filter?: (route: Route) => boolean;
311
311
  }): Promise<void>;
312
312
  }
313
+ type QueryRouterServerOpts = {
314
+ handleFn?: HandleFn;
315
+ context?: RouteContext;
316
+ appId?: string;
317
+ };
313
318
  interface HandleFn<T = any> {
314
319
  (msg: {
315
320
  path: string;
@@ -322,10 +327,43 @@ interface HandleFn<T = any> {
322
327
  };
323
328
  (res: RouteContext<T>): any;
324
329
  }
330
+ /**
331
+ * QueryRouterServer
332
+ * @description 移除server相关的功能,只保留router相关的功能,和http.createServer不相关,独立
333
+ */
334
+ declare class QueryRouterServer extends QueryRouter {
335
+ appId: string;
336
+ handle: any;
337
+ constructor(opts?: QueryRouterServerOpts);
338
+ setHandle(wrapperFn?: HandleFn, ctx?: RouteContext): void;
339
+ use(path: string, fn: (ctx: any) => any, opts?: RouteOpts): void;
340
+ addRoute(route: Route): void;
341
+ Route: typeof Route;
342
+ route(opts: RouteOpts): Route<Required<RouteContext>>;
343
+ route(path: string, key?: string): Route<Required<RouteContext>>;
344
+ route(path: string, opts?: RouteOpts): Route<Required<RouteContext>>;
345
+ route(path: string, key?: string, opts?: RouteOpts): Route<Required<RouteContext>>;
346
+ prompt(description: string): Route<Required<RouteContext>>;
347
+ prompt(description: Function): Route<Required<RouteContext>>;
348
+ /**
349
+ * 调用了handle
350
+ * @param param0
351
+ * @returns
352
+ */
353
+ run(msg: {
354
+ id?: string;
355
+ path?: string;
356
+ key?: string;
357
+ payload?: any;
358
+ }, ctx?: RouteContext & {
359
+ [key: string]: any;
360
+ }): Promise<any>;
361
+ }
325
362
 
363
+ declare const addCallFn: (app: QueryRouterServer) => void;
326
364
  declare const createRouterAgentPluginFn: (opts?: {
327
365
  router?: QueryRouter;
328
366
  query?: string;
329
367
  }) => Plugin;
330
368
 
331
- export { createRouterAgentPluginFn };
369
+ export { addCallFn, createRouterAgentPluginFn };