koa-ts-core 0.0.16 → 0.0.18

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.
@@ -2,11 +2,14 @@ import Koa from "koa";
2
2
  import { TErrorCallback } from '../middleware/exception_middleware';
3
3
  import { appRouter } from '../router';
4
4
  import type { AuthRouterCallback } from '../types/route';
5
+ import { TLog4 } from "./register_log";
5
6
  export type TInitOPtions = Partial<{
6
7
  koaInstance: Koa;
7
8
  authCheckCallback: AuthRouterCallback;
8
9
  catchErrorCallback: TErrorCallback;
9
10
  registerHighPriorityMiddleware: (app: Koa) => void;
11
+ registerHook: (ctx: Koa.Context, type: "request" | "response" | "error") => void;
12
+ log4: TLog4;
10
13
  }>;
11
14
  /**
12
15
  * 初始化core
@@ -0,0 +1,10 @@
1
+ import log4js, { Log4js } from "log4js";
2
+ export type TLog4 = boolean | ((instance: Log4js) => Log4js);
3
+ /**
4
+ * 注册log4
5
+ * 如果log4为true,则使用默认配置
6
+ * @param log4
7
+ * @returns
8
+ */
9
+ declare const registerLog4: (log4: TLog4) => log4js.Log4js | undefined;
10
+ export default registerLog4;
@@ -1,10 +1,12 @@
1
1
  import BaseException from '../base/exception';
2
2
  import type Koa from "koa";
3
3
  export type TErrorCallback = (error: Error | BaseException, ctx: Koa.Context) => void;
4
+ type TErrorHook = (ctx: Koa.Context) => void;
4
5
  /**
5
6
  * 错误处理中间件
7
+ * @param {TErrorHook} errorHook
6
8
  * @param {TErrorCallback} catchCallback
7
9
  * @returns
8
10
  */
9
- declare const catchErrorMiddleware: (catchCallback?: TErrorCallback) => (ctx: Koa.Context, next: Koa.Next) => Promise<void>;
11
+ declare const catchErrorMiddleware: (errorHook: TErrorHook, catchCallback?: TErrorCallback) => (ctx: Koa.Context, next: Koa.Next) => Promise<void>;
10
12
  export default catchErrorMiddleware;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koa-ts-core",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "koa-ts-core",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -28,8 +28,10 @@
28
28
  "dotenv": "^16.4.7",
29
29
  "koa": "^2.15.4",
30
30
  "koa-bodyparser": "^4.4.1",
31
+ "log4js": "^6.9.1",
31
32
  "portfinder": "^1.0.37",
32
33
  "pug": "^3.0.3",
34
+ "rollup-plugin-copy-and-reference-dts": "0.0.2",
33
35
  "rollup-plugin-pug": "^1.1.1"
34
36
  },
35
37
  "devDependencies": {
@@ -46,6 +48,7 @@
46
48
  "rollup": "^4.34.9",
47
49
  "rollup-plugin-copy": "^3.5.0",
48
50
  "rollup-plugin-delete": "^2.1.0",
51
+ "rollup-plugin-dts": "^6.2.3",
49
52
  "rollup-plugin-dts-alias": "^0.0.4",
50
53
  "typescript": "^5.7.3"
51
54
  },