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.
- package/README.md +11 -1
- package/dist/global.d.ts +9 -0
- package/dist/index.cjs.js +8 -8
- package/dist/index.esm.js +8 -8
- package/dist/init/index.d.ts +3 -1
- package/dist/middleware/exception_middleware.d.ts +1 -3
- package/dist/middleware/logger_middleware.d.ts +6 -0
- package/dist/middleware/request_params_middleware.d.ts +1 -1
- package/package.json +1 -1
package/dist/init/index.d.ts
CHANGED
|
@@ -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: (
|
|
9
|
+
declare const catchErrorMiddleware: (catchCallback?: TErrorCallback) => (ctx: Koa.Context, next: Koa.Next) => Promise<void>;
|
|
12
10
|
export default catchErrorMiddleware;
|