koa-ts-core 0.0.23 → 0.0.25

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.
@@ -1,15 +1,17 @@
1
- import Koa from "koa";
2
1
  import { TErrorCallback } from '../middleware/exception_middleware';
3
2
  import { appRouter } from '../router';
4
3
  import type { AuthRouterCallback } from '../types/route';
4
+ import Koa from "koa";
5
5
  import { TLog4 } from "./register_log";
6
6
  export type TInitOPtions = Partial<{
7
7
  koaInstance: Koa;
8
+ corsMiddleware: Koa.Middleware;
8
9
  authCheckCallback: AuthRouterCallback;
9
10
  catchErrorCallback: TErrorCallback;
10
11
  registerHighPriorityMiddleware: (app: Koa) => void;
11
12
  registerHook: (ctx: Koa.Context, type: "request" | "response" | "error") => void;
12
13
  log4: TLog4;
14
+ runtimeLog: boolean;
13
15
  }>;
14
16
  /**
15
17
  * 初始化core
@@ -1,12 +1,10 @@
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;
5
4
  /**
6
5
  * 错误处理中间件
7
- * @param {TErrorHook} errorHook
8
6
  * @param {TErrorCallback} catchCallback
9
7
  * @returns
10
8
  */
11
- declare const catchErrorMiddleware: (errorHook: TErrorHook, catchCallback?: TErrorCallback) => (ctx: Koa.Context, next: Koa.Next) => Promise<void>;
9
+ declare const catchErrorMiddleware: (catchCallback?: TErrorCallback) => (ctx: Koa.Context, next: Koa.Next) => Promise<void>;
12
10
  export default catchErrorMiddleware;
@@ -0,0 +1,6 @@
1
+ import type { Middleware } from "koa";
2
+ /**
3
+ * 日志中间件
4
+ * 使用 app.context.log4 输出访问日志与错误日志
5
+ */
6
+ export declare const loggerMiddleware: Middleware;
@@ -1,6 +1,6 @@
1
1
  import { Middleware } from "koa";
2
2
  /**
3
- * 往global添加属性
3
+ * 把请求参数挂载到 ctx.extra 上
4
4
  * @param ctx
5
5
  */
6
6
  declare const requestParamsMiddleware: Middleware;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koa-ts-core",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "description": "koa-ts-core",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",