koa-ts-core 0.0.23 → 0.0.24

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 CHANGED
@@ -29,6 +29,8 @@ const [app] = await initializeKoaApp({
29
29
  ) => void;
30
30
  // 是否挂载log4到context
31
31
  log4: TLog4;
32
+ // 是否挂载运行时日志
33
+ runtimeLog: boolean;
32
34
  });
33
35
 
34
36
  app.listen();
@@ -52,8 +54,16 @@ app.listen();
52
54
 
53
55
  - log4 (TLog4) : 是否挂载 log4 到 context
54
56
 
57
+ - runtimeLog (boolean) : 是否挂载运行时日志
58
+
55
59
  ## 能力
56
60
 
61
+ ### 内置部分中间件
62
+
63
+ #### 按优先级排序
64
+
65
+ 全局错误处理 => AsyncLocalStorage 上下文中间件 => 请求日志 / 响应时间统计 => CORS / 安全相关 => 解析 body => 鉴权 => 路由
66
+
57
67
  ### 约定式路由
58
68
 
59
69
  控制器注册路由,约定在`src/controller`目录下.ts 文件,使用`@Router`和`@AuthRouter`装饰器注册路由
@@ -156,7 +166,7 @@ export default Test;
156
166
 
157
167
  #### 装饰器实现
158
168
 
159
- `@Router`和`@AuthRouter`装饰器本质是基于[@koa/router](https://www.npmjs.com/package/@koa/router)进行封装
169
+ `@Router`和`@AuthRouter`装饰器实现是基于[@koa/router](https://www.npmjs.com/package/@koa/router)进行封装
160
170
 
161
171
  ps:路由参数参考[path-to-regexp](https://github.com/pillarjs/path-to-regexp)
162
172
 
package/dist/global.d.ts CHANGED
@@ -4,6 +4,10 @@ declare module "koa" {
4
4
  interface DefaultContext {
5
5
  // log4js
6
6
  log4?: import("log4js").Log4js;
7
+ // hook
8
+ hook?: (ctx: Koa.Context, type: "request" | "response" | "error") => void;
9
+ // runtimeLog
10
+ runtimeLog: boolean;
7
11
  // 验证过的参数
8
12
  validated: {
9
13
  params: Record<string, any>;