soonjs 0.0.20 → 0.0.21

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.
package/dist/index.d.ts CHANGED
@@ -15,6 +15,11 @@ export interface Config {
15
15
  }
16
16
  export interface ServiceContext {
17
17
  }
18
+ export interface Extensions {
19
+ }
20
+ export interface Namespace {
21
+ default: any;
22
+ }
18
23
  export { Context, SoonFetchOptions };
19
24
  export type ReturnRealType<T extends (...args: any) => any | Promise<(...args: any) => any>, R = ReturnType<T>> = R extends Promise<infer U> ? U : R;
20
25
  export type ReturnConfig<ConfigDefine extends () => any, T = ReturnType<ConfigDefine>> = T extends Promise<infer U> ? U : T;
@@ -26,6 +31,7 @@ export declare class SoonApp {
26
31
  private api404;
27
32
  private fnMiddleware;
28
33
  private getId;
34
+ private extensions;
29
35
  config: Config;
30
36
  apiList: APIOptions[];
31
37
  constructor(options?: SoonAppOptions, callback?: (error: any, app: SoonApp) => void);
@@ -35,6 +41,8 @@ export declare class SoonApp {
35
41
  */
36
42
  fetchRaw(url: string, body?: any, soonFetchOptions?: SoonFetchOptions): Promise<Response<any>>;
37
43
  fetch(url: string, body?: any, soonFetchOptions?: SoonFetchOptions): Promise<any>;
44
+ mount(extensionName: string, extension: any): void;
45
+ get<T extends keyof Extensions>(extensionName: T): Extensions[T];
38
46
  }
39
47
  export declare const soonApiSymbol: unique symbol;
40
48
  /**
@@ -59,6 +67,8 @@ export declare function defineApi<BodySchema extends ZodType<any, any, any>, Cus
59
67
  desc?: string;
60
68
  tags?: string[];
61
69
  meta?: Meta;
70
+ middlewares?: Middleware[];
71
+ namespace?: keyof Namespace;
62
72
  /**
63
73
  * api body 验证模式
64
74
  */