kb-server 0.0.1-beta.3 → 0.0.1-beta.4
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.
|
@@ -23,7 +23,15 @@ export interface APIErrorResponse {
|
|
|
23
23
|
RequestId: string;
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
export type AuthFunction = (
|
|
26
|
+
export type AuthFunction = (
|
|
27
|
+
/**
|
|
28
|
+
* API名称
|
|
29
|
+
*/
|
|
30
|
+
action: string,
|
|
31
|
+
/**
|
|
32
|
+
* Express原始请求
|
|
33
|
+
*/
|
|
34
|
+
req: express.Request) => Promise<Record<string, any> | false> | false | Record<string, any>;
|
|
27
35
|
interface IPackAPIOptions {
|
|
28
36
|
authFn?: AuthFunction;
|
|
29
37
|
}
|
|
@@ -6,7 +6,11 @@ export interface ServerContext {
|
|
|
6
6
|
AuthInfo?: Record<string, any>;
|
|
7
7
|
}
|
|
8
8
|
export type API<P, R> = (param: P) => Promise<R>;
|
|
9
|
-
export type APIExecution<P, R> = (
|
|
9
|
+
export type APIExecution<P, R> = (
|
|
10
|
+
/** 请求入参 */
|
|
11
|
+
params: P,
|
|
12
|
+
/** 请求上下文 */
|
|
13
|
+
ctx: ServerContext) => Promise<R>;
|
|
10
14
|
export type AnyAPIExecution = APIExecution<any, any>;
|
|
11
15
|
export type APIs = Record<string, AnyAPIExecution>;
|
|
12
16
|
export declare function createAPI<P, R>(ParamsClass: Class<P>, execution: APIExecution<P, R>): API<P, R>;
|