kb-server 0.0.1-beta.13 → 0.0.1-beta.15

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.
@@ -63,7 +63,7 @@ const packAPI = (apis, options) => {
63
63
  };
64
64
  // 完成响应
65
65
  took = Date.now() - start;
66
- logger_1.logger.log("info", response);
66
+ logger_1.logger.log("info", `响应:${JSON.stringify(response)}`);
67
67
  logger_1.logger.log("info", `耗时:${took} ms - RequestId: ${requestId}`);
68
68
  return res.send(response);
69
69
  }
@@ -90,7 +90,7 @@ const packAPI = (apis, options) => {
90
90
  };
91
91
  // 完成响应
92
92
  took = Date.now() - start;
93
- logger_1.logger.log("info", response);
93
+ logger_1.logger.log("info", `响应:${JSON.stringify(response)}`);
94
94
  logger_1.logger.log("info", `耗时:${took} ms - RequestId: ${requestId}`);
95
95
  return res.send(response);
96
96
  }
@@ -1,19 +1,19 @@
1
1
  import { Class } from "utility-types";
2
- export interface ServerContext {
2
+ export interface ServerContext<A = any> {
3
3
  /** 被调用方的 RequestId */
4
4
  RequestId: string;
5
5
  /** 权限信息 */
6
- AuthInfo?: Record<string, any>;
6
+ AuthInfo?: A;
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, A> = (
10
10
  /** 请求入参 */
11
11
  params: P,
12
12
  /** 请求上下文 */
13
- ctx: ServerContext) => Promise<R>;
14
- export type AnyAPIExecution = APIExecution<any, any>;
13
+ ctx: ServerContext<A>) => Promise<R>;
14
+ export type AnyAPIExecution = APIExecution<any, any, any>;
15
15
  export type APIs = Record<string, AnyAPIExecution>;
16
- export declare function createAPI<P, R>(ParamsClass: Class<P>, execution: APIExecution<P, R>): API<P, R>;
16
+ export declare function createAPI<P, R, A>(ParamsClass: Class<P>, execution: APIExecution<P, R, A>): API<P, R>;
17
17
  type StubParam<T> = T extends (params: infer P) => any ? P : never;
18
- export declare function implementAPI<A extends (params: any) => any>(_actionStub: A, ParamsClass: Class<StubParam<A>>, execution: APIExecution<StubParam<A>, ReturnType<A>>): API<StubParam<A>, ReturnType<A>>;
18
+ export declare function implementAPI<F extends (params: any) => any, A>(_actionStub: F, ParamsClass: Class<StubParam<F>>, execution: APIExecution<StubParam<F>, ReturnType<F>, A>): API<StubParam<F>, ReturnType<F>>;
19
19
  export {};
@@ -7,7 +7,7 @@ exports.logger = void 0;
7
7
  const moment_1 = __importDefault(require("moment"));
8
8
  exports.logger = { log };
9
9
  function log(level, message) {
10
- const logTime = (0, moment_1.default)().format(`YYYY-MM-DD HH:ss:mm`);
10
+ const logTime = (0, moment_1.default)().format(`YYYY-MM-DD HH:mm:ss`);
11
11
  if (typeof message === "string") {
12
12
  console.log(`[${level}] - [${logTime}] - ${message}`);
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kb-server",
3
- "version": "0.0.1-beta.13",
3
+ "version": "0.0.1-beta.15",
4
4
  "description": "A fast server for Node.JS,made by express.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {