kb-server 0.0.1-beta.2 → 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 = (action: string, req: express.Request) => Promise<Record<string, any> | false>;
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> = (params: P, ctx: ServerContext) => Promise<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>;
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "kb-server",
3
- "version": "0.0.1-beta.2",
3
+ "version": "0.0.1-beta.4",
4
4
  "description": "A fast server for Node.JS,made by express.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
- "build": "tsc",
7
+ "build": "rm -rf ./dist & tsc",
8
8
  "test": "echo \"Error: no test specified\" && exit 1"
9
9
  },
10
10
  "keywords": [