zenweb 6.2.0 → 6.4.0
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/AGENTS.md +276 -0
- package/README.md +18 -12
- package/dist/index.d.ts +2 -2
- package/dist/index.js +78 -30
- package/dist/types.js +2 -1
- package/package.json +17 -17
package/AGENTS.md
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
AI 专用 API 参考文档,随 npm 包发布,供 AI 编程助手使用。
|
|
4
|
+
|
|
5
|
+
## 模块概述
|
|
6
|
+
|
|
7
|
+
ZenWeb 是基于 Koa 的模块化轻量级 Web 框架。`create()` 函数整合了多个常用模块,简化新项目配置,无需单独安装已集成模块。各模块详细用法请参阅其各自的 AGENTS.md 文件。
|
|
8
|
+
|
|
9
|
+
## 导出
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
// 主函数
|
|
13
|
+
export { create, Core, CreateOptions };
|
|
14
|
+
|
|
15
|
+
// 依赖注入
|
|
16
|
+
export { Init, Inject, Injectable, $getInstance } from '@zenweb/inject';
|
|
17
|
+
|
|
18
|
+
// 路由
|
|
19
|
+
export { Router, RouterMethod, RouterPath } from '@zenweb/router';
|
|
20
|
+
|
|
21
|
+
// 结果处理
|
|
22
|
+
export { ResultFail, fail } from '@zenweb/result';
|
|
23
|
+
|
|
24
|
+
// 控制器装饰器
|
|
25
|
+
export {
|
|
26
|
+
Controller,
|
|
27
|
+
Mapping,
|
|
28
|
+
Get,
|
|
29
|
+
Post,
|
|
30
|
+
Put,
|
|
31
|
+
Patch,
|
|
32
|
+
Delete,
|
|
33
|
+
All,
|
|
34
|
+
} from '@zenweb/controller';
|
|
35
|
+
|
|
36
|
+
// Core 相关
|
|
37
|
+
export {
|
|
38
|
+
Next,
|
|
39
|
+
SetupFunction,
|
|
40
|
+
Context,
|
|
41
|
+
Middleware,
|
|
42
|
+
SetupHelper,
|
|
43
|
+
$getCore,
|
|
44
|
+
$getContext,
|
|
45
|
+
$core,
|
|
46
|
+
$ctx,
|
|
47
|
+
$debug,
|
|
48
|
+
createDebug,
|
|
49
|
+
} from '@zenweb/core';
|
|
50
|
+
|
|
51
|
+
// Body 解析
|
|
52
|
+
export {
|
|
53
|
+
Body,
|
|
54
|
+
ObjectBody,
|
|
55
|
+
BodyHelper,
|
|
56
|
+
RawBody,
|
|
57
|
+
TextBody,
|
|
58
|
+
useBodyParser,
|
|
59
|
+
$body,
|
|
60
|
+
$getTextBody,
|
|
61
|
+
$getRawBody,
|
|
62
|
+
$getObjectBody,
|
|
63
|
+
} from '@zenweb/body';
|
|
64
|
+
|
|
65
|
+
// Helper
|
|
66
|
+
export {
|
|
67
|
+
QueryHelper,
|
|
68
|
+
TypeCastHelper,
|
|
69
|
+
ParamHelper,
|
|
70
|
+
$param,
|
|
71
|
+
$query,
|
|
72
|
+
$helperBase,
|
|
73
|
+
} from '@zenweb/helper';
|
|
74
|
+
|
|
75
|
+
// Log
|
|
76
|
+
export {
|
|
77
|
+
$log,
|
|
78
|
+
$getLogger,
|
|
79
|
+
Logger,
|
|
80
|
+
} from '@zenweb/log';
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## create(options?: CreateOptions)
|
|
84
|
+
|
|
85
|
+
创建应用实例,自动安装集成模块。
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { create } from 'zenweb';
|
|
89
|
+
|
|
90
|
+
create({
|
|
91
|
+
// 全局实例,默认 true
|
|
92
|
+
global: true,
|
|
93
|
+
|
|
94
|
+
// 模块配置,设为 false 可禁用
|
|
95
|
+
core: { env: 'production', keys: ['secret'] },
|
|
96
|
+
meta: { showVersion: true, traceId: true },
|
|
97
|
+
inject: false, // 禁用注入
|
|
98
|
+
log: { dir: '/var/log/app' },
|
|
99
|
+
router: false, // 禁用路由
|
|
100
|
+
messagecode: { codes: { 'error': '错误' } },
|
|
101
|
+
body: { limit: 1024 * 1024 },
|
|
102
|
+
result: { failCode: 1, failStatus: 200 },
|
|
103
|
+
helper: { page: { defaultLimit: 20 } },
|
|
104
|
+
controller: { discoverPaths: ['./controller'], autoControllerPrefix: true },
|
|
105
|
+
})
|
|
106
|
+
.start();
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## CreateOptions 类型
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
interface CreateOptions {
|
|
113
|
+
global?: boolean; // 全局实例,默认 true
|
|
114
|
+
core?: CoreOption; // @zenweb/core 配置
|
|
115
|
+
inject?: false; // 禁用 @zenweb/inject
|
|
116
|
+
meta?: MetaOption | false; // @zenweb/meta 配置或禁用
|
|
117
|
+
log?: LogOption | false; // @zenweb/log 配置或禁用
|
|
118
|
+
router?: false; // 禁用 @zenweb/router
|
|
119
|
+
messagecode?: MessageCodeOption | false;
|
|
120
|
+
body?: BodyOption | false;
|
|
121
|
+
result?: ResultOption | false;
|
|
122
|
+
helper?: HelperOption | false;
|
|
123
|
+
controller?: ControllerSetupOption | false;
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## 集成模块列表
|
|
128
|
+
|
|
129
|
+
以下模块已集成,无需单独安装。详细 API 请参阅各模块 AGENTS.md:
|
|
130
|
+
|
|
131
|
+
| 模块 | 作用 | 默认状态 |
|
|
132
|
+
|------|------|----------|
|
|
133
|
+
| `@zenweb/core` | 核心应用和上下文管理 | 启用 |
|
|
134
|
+
| `@zenweb/meta` | 请求元信息(耗时、请求ID、追踪ID) | 启用 |
|
|
135
|
+
| `@zenweb/inject` | 依赖注入系统 | 启用 |
|
|
136
|
+
| `@zenweb/router` | Trie 高性能路由 | 启用 |
|
|
137
|
+
| `@zenweb/log` | 请求日志 | 启用 |
|
|
138
|
+
| `@zenweb/result` | 统一成功/失败响应处理 | 启用 |
|
|
139
|
+
| `@zenweb/messagecode` | 错误消息代码格式化 | 启用 |
|
|
140
|
+
| `@zenweb/controller` | 类控制器装饰器路由 | 启用 |
|
|
141
|
+
| `@zenweb/helper` | 输入验证和类型转换助手 | 启用 |
|
|
142
|
+
| `@zenweb/body` | 请求主体解析(JSON、Form) | 启用 |
|
|
143
|
+
|
|
144
|
+
## 可选扩展模块
|
|
145
|
+
|
|
146
|
+
以下模块需单独安装:
|
|
147
|
+
|
|
148
|
+
- `@zenweb/cors` - 跨域支持
|
|
149
|
+
- `@zenweb/sentry` - Sentry 错误收集
|
|
150
|
+
- `@zenweb/metric` - 生产运行健康信息
|
|
151
|
+
- `@zenweb/validation` - JSONSchema 验证
|
|
152
|
+
- `@zenweb/mysql` - MySQL 数据库
|
|
153
|
+
- `@zenweb/orm` - ORM 支持
|
|
154
|
+
- `@zenweb/template` - 模板渲染
|
|
155
|
+
- `@zenweb/schedule` - 定时任务
|
|
156
|
+
- `@zenweb/form` - 统一表单
|
|
157
|
+
- `@zenweb/grid` - 统一表格
|
|
158
|
+
- `@zenweb/upload` - 文件上传
|
|
159
|
+
- `@zenweb/xml-body` - XML Body 解析
|
|
160
|
+
- `@zenweb/msgpack` - MessagePack 输出
|
|
161
|
+
|
|
162
|
+
## 全局 Helper ($前缀)
|
|
163
|
+
|
|
164
|
+
基于 AsyncLocalStorage,请求期间可在任意位置调用:
|
|
165
|
+
|
|
166
|
+
```ts
|
|
167
|
+
// Body 解析和类型转换
|
|
168
|
+
await $body.get({ name: 'string', age: '!int' });
|
|
169
|
+
await $body.page({ limit: 10 });
|
|
170
|
+
await $getObjectBody();
|
|
171
|
+
|
|
172
|
+
// Query 和 Param
|
|
173
|
+
await $query.get({ id: '!int' });
|
|
174
|
+
await $query.page();
|
|
175
|
+
await $param.data();
|
|
176
|
+
|
|
177
|
+
// 日志
|
|
178
|
+
$log.info('message');
|
|
179
|
+
$log.child({ extra: 'field' }).debug('debug msg');
|
|
180
|
+
|
|
181
|
+
// 上下文和 Core
|
|
182
|
+
const ctx = $ctx;
|
|
183
|
+
const core = $getCore();
|
|
184
|
+
const ip = $ctx.ip;
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## 依赖注入
|
|
188
|
+
|
|
189
|
+
使用 TypeScript 装饰器(需 `experimentalDecorators` 和 `emitDecoratorMetadata`):
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
@Injectable // 请求级服务(默认)
|
|
193
|
+
@Injectable('singleton') // 单例服务
|
|
194
|
+
|
|
195
|
+
class MyService {
|
|
196
|
+
constructor(private ctx: Context) {} // 自动注入 Context
|
|
197
|
+
|
|
198
|
+
@Init // 初始化方法
|
|
199
|
+
init(other: OtherService) {}
|
|
200
|
+
|
|
201
|
+
@Inject other!: OtherService; // 属性注入
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// 控制器方法参数自动注入
|
|
205
|
+
@Get()
|
|
206
|
+
handler(service: MyService) {}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## 控制器模式
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
export class UserController {
|
|
213
|
+
@Get() // GET /user (方法名作为路径)
|
|
214
|
+
index() { return 'list'; }
|
|
215
|
+
|
|
216
|
+
@Get('/:id') // GET /user/:id
|
|
217
|
+
detail() {
|
|
218
|
+
return $param.data(); // 获取路由参数
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
@Post() // POST /user
|
|
222
|
+
create() {
|
|
223
|
+
return $body.get({ name: '!string', email: 'string' });
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
@Put('/:id')
|
|
227
|
+
update() {}
|
|
228
|
+
|
|
229
|
+
@Delete('/:id')
|
|
230
|
+
remove() {}
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
`controller.discoverPaths` 配置控制器目录,`autoControllerPrefix: true` 自动将文件路径映射为路由前缀。
|
|
235
|
+
|
|
236
|
+
## 错误处理
|
|
237
|
+
|
|
238
|
+
```ts
|
|
239
|
+
import { fail } from 'zenweb';
|
|
240
|
+
|
|
241
|
+
// 立即终止并返回错误响应
|
|
242
|
+
fail('错误消息');
|
|
243
|
+
fail(400, '参数错误');
|
|
244
|
+
fail({ code: 123, message: '自定义错误', status: 200 });
|
|
245
|
+
|
|
246
|
+
// controller 方法 return 值自动包装为成功响应
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## TypeScript 配置要求
|
|
250
|
+
|
|
251
|
+
```json
|
|
252
|
+
{
|
|
253
|
+
"compilerOptions": {
|
|
254
|
+
"experimentalDecorators": true,
|
|
255
|
+
"emitDecoratorMetadata": true,
|
|
256
|
+
"target": "ES2020",
|
|
257
|
+
"module": "commonjs",
|
|
258
|
+
"strict": true
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## 各模块 AGENTS.md 位置
|
|
264
|
+
|
|
265
|
+
安装后可读取以下文件获取详细 API:
|
|
266
|
+
|
|
267
|
+
- `node_modules/@zenweb/core/AGENTS.md`
|
|
268
|
+
- `node_modules/@zenweb/meta/AGENTS.md`
|
|
269
|
+
- `node_modules/@zenweb/inject/AGENTS.md`
|
|
270
|
+
- `node_modules/@zenweb/router/AGENTS.md`
|
|
271
|
+
- `node_modules/@zenweb/log/AGENTS.md`
|
|
272
|
+
- `node_modules/@zenweb/result/AGENTS.md`
|
|
273
|
+
- `node_modules/@zenweb/messagecode/AGENTS.md`
|
|
274
|
+
- `node_modules/@zenweb/controller/AGENTS.md`
|
|
275
|
+
- `node_modules/@zenweb/helper/AGENTS.md`
|
|
276
|
+
- `node_modules/@zenweb/body/AGENTS.md`
|
package/README.md
CHANGED
|
@@ -10,10 +10,10 @@ Modular lightweight web framework based on Koa
|
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
12
|
# for production
|
|
13
|
-
npm
|
|
13
|
+
npm i zenweb
|
|
14
14
|
|
|
15
15
|
# for development
|
|
16
|
-
npm
|
|
16
|
+
npm i -D dotenv typescript rimraf tsc-watch
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Project Code
|
|
@@ -33,9 +33,19 @@ create `tsconfig.json` file
|
|
|
33
33
|
|
|
34
34
|
```json
|
|
35
35
|
{
|
|
36
|
-
|
|
36
|
+
{
|
|
37
37
|
"compilerOptions": {
|
|
38
|
-
"
|
|
38
|
+
"experimentalDecorators": true,
|
|
39
|
+
"emitDecoratorMetadata": true,
|
|
40
|
+
"target": "ES2020",
|
|
41
|
+
"module": "commonjs",
|
|
42
|
+
"types": [ "node" ],
|
|
43
|
+
"esModuleInterop": true,
|
|
44
|
+
"strict": true,
|
|
45
|
+
"sourceMap": true,
|
|
46
|
+
"newLine": "lf",
|
|
47
|
+
"rootDir": "src",
|
|
48
|
+
"outDir": "app"
|
|
39
49
|
},
|
|
40
50
|
"include": ["src/**/*"]
|
|
41
51
|
}
|
|
@@ -59,9 +69,9 @@ create().start();
|
|
|
59
69
|
create `src/service/hello.ts` file
|
|
60
70
|
|
|
61
71
|
```ts
|
|
62
|
-
import {
|
|
72
|
+
import { Injectable, Context } from 'zenweb';
|
|
63
73
|
|
|
64
|
-
@
|
|
74
|
+
@Injectable
|
|
65
75
|
export class HelloService {
|
|
66
76
|
constructor(
|
|
67
77
|
private ctx: Context,
|
|
@@ -94,7 +104,7 @@ start server:
|
|
|
94
104
|
npm run dev
|
|
95
105
|
```
|
|
96
106
|
|
|
97
|
-
##
|
|
107
|
+
## 集成模块
|
|
98
108
|
- [core](https://www.npmjs.com/package/@zenweb/core) 核心
|
|
99
109
|
- [meta](https://www.npmjs.com/package/@zenweb/meta) 运行基本信息,例如:请求耗时
|
|
100
110
|
- [inject](https://www.npmjs.com/package/@zenweb/inject) 注入支持
|
|
@@ -102,15 +112,11 @@ npm run dev
|
|
|
102
112
|
- [log](https://www.npmjs.com/package/@zenweb/log) 日志支持
|
|
103
113
|
- [result](https://www.npmjs.com/package/@zenweb/result) 统一结果返回,成功或失败
|
|
104
114
|
- [messagecode](https://www.npmjs.com/package/@zenweb/messagecode) 统一错误消息格式化
|
|
105
|
-
- 依赖 inject, result
|
|
106
115
|
- [controller](https://www.npmjs.com/package/@zenweb/controller) 类控制器支持
|
|
107
|
-
- 依赖 inject, router
|
|
108
116
|
- [helper](https://www.npmjs.com/package/@zenweb/helper) 输入数据验证助手
|
|
109
|
-
- 依赖 inject, messagecode
|
|
110
117
|
- [body](https://www.npmjs.com/package/@zenweb/body) 请求主体解析,JSON、Form
|
|
111
|
-
- 依赖 inject, helper
|
|
112
118
|
|
|
113
|
-
|
|
119
|
+
集成模块默认开启,可以通过设置配置项为 **false** 关闭
|
|
114
120
|
|
|
115
121
|
|
|
116
122
|
## 可选模块
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Core } from '@zenweb/core';
|
|
2
|
-
import { CreateOptions } from './types
|
|
3
|
-
export { Init, Inject,
|
|
2
|
+
import { CreateOptions } from './types';
|
|
3
|
+
export { Init, Inject, Injectable, $getInstance } from '@zenweb/inject';
|
|
4
4
|
export { Router, RouterMethod, RouterPath } from '@zenweb/router';
|
|
5
5
|
export { ResultFail, fail } from '@zenweb/result';
|
|
6
6
|
export { Controller, Mapping, Get, Post, Put, Patch, Delete, All, } from '@zenweb/controller';
|
package/dist/index.js
CHANGED
|
@@ -1,46 +1,94 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Core = exports.$getLogger = exports.$log = exports.$helperBase = exports.$query = exports.$param = exports.ParamHelper = exports.TypeCastHelper = exports.QueryHelper = exports.$getObjectBody = exports.$getRawBody = exports.$getTextBody = exports.$body = exports.useBodyParser = exports.TextBody = exports.RawBody = exports.BodyHelper = exports.ObjectBody = exports.Body = exports.createDebug = exports.$debug = exports.$ctx = exports.$core = exports.$getContext = exports.$getCore = exports.SetupHelper = exports.Context = exports.All = exports.Delete = exports.Patch = exports.Put = exports.Post = exports.Get = exports.Mapping = exports.Controller = exports.fail = exports.ResultFail = exports.Router = exports.$getInstance = exports.Injectable = exports.Inject = exports.Init = void 0;
|
|
7
|
+
exports.create = create;
|
|
8
|
+
const inject_1 = __importDefault(require("@zenweb/inject"));
|
|
9
|
+
const meta_1 = __importDefault(require("@zenweb/meta"));
|
|
10
|
+
const log_1 = __importDefault(require("@zenweb/log"));
|
|
11
|
+
const router_1 = __importDefault(require("@zenweb/router"));
|
|
12
|
+
const messagecode_1 = __importDefault(require("@zenweb/messagecode"));
|
|
13
|
+
const body_1 = __importDefault(require("@zenweb/body"));
|
|
14
|
+
const result_1 = __importDefault(require("@zenweb/result"));
|
|
15
|
+
const helper_1 = __importDefault(require("@zenweb/helper"));
|
|
16
|
+
const controller_1 = __importDefault(require("@zenweb/controller"));
|
|
17
|
+
const core_1 = require("@zenweb/core");
|
|
18
|
+
Object.defineProperty(exports, "Core", { enumerable: true, get: function () { return core_1.Core; } });
|
|
19
|
+
var inject_2 = require("@zenweb/inject");
|
|
20
|
+
Object.defineProperty(exports, "Init", { enumerable: true, get: function () { return inject_2.Init; } });
|
|
21
|
+
Object.defineProperty(exports, "Inject", { enumerable: true, get: function () { return inject_2.Inject; } });
|
|
22
|
+
Object.defineProperty(exports, "Injectable", { enumerable: true, get: function () { return inject_2.Injectable; } });
|
|
23
|
+
Object.defineProperty(exports, "$getInstance", { enumerable: true, get: function () { return inject_2.$getInstance; } });
|
|
24
|
+
var router_2 = require("@zenweb/router");
|
|
25
|
+
Object.defineProperty(exports, "Router", { enumerable: true, get: function () { return router_2.Router; } });
|
|
26
|
+
var result_2 = require("@zenweb/result");
|
|
27
|
+
Object.defineProperty(exports, "ResultFail", { enumerable: true, get: function () { return result_2.ResultFail; } });
|
|
28
|
+
Object.defineProperty(exports, "fail", { enumerable: true, get: function () { return result_2.fail; } });
|
|
29
|
+
var controller_2 = require("@zenweb/controller");
|
|
30
|
+
Object.defineProperty(exports, "Controller", { enumerable: true, get: function () { return controller_2.Controller; } });
|
|
31
|
+
Object.defineProperty(exports, "Mapping", { enumerable: true, get: function () { return controller_2.Mapping; } });
|
|
32
|
+
Object.defineProperty(exports, "Get", { enumerable: true, get: function () { return controller_2.Get; } });
|
|
33
|
+
Object.defineProperty(exports, "Post", { enumerable: true, get: function () { return controller_2.Post; } });
|
|
34
|
+
Object.defineProperty(exports, "Put", { enumerable: true, get: function () { return controller_2.Put; } });
|
|
35
|
+
Object.defineProperty(exports, "Patch", { enumerable: true, get: function () { return controller_2.Patch; } });
|
|
36
|
+
Object.defineProperty(exports, "Delete", { enumerable: true, get: function () { return controller_2.Delete; } });
|
|
37
|
+
Object.defineProperty(exports, "All", { enumerable: true, get: function () { return controller_2.All; } });
|
|
38
|
+
var core_2 = require("@zenweb/core");
|
|
39
|
+
Object.defineProperty(exports, "Context", { enumerable: true, get: function () { return core_2.Context; } });
|
|
40
|
+
Object.defineProperty(exports, "SetupHelper", { enumerable: true, get: function () { return core_2.SetupHelper; } });
|
|
41
|
+
Object.defineProperty(exports, "$getCore", { enumerable: true, get: function () { return core_2.$getCore; } });
|
|
42
|
+
Object.defineProperty(exports, "$getContext", { enumerable: true, get: function () { return core_2.$getContext; } });
|
|
43
|
+
Object.defineProperty(exports, "$core", { enumerable: true, get: function () { return core_2.$core; } });
|
|
44
|
+
Object.defineProperty(exports, "$ctx", { enumerable: true, get: function () { return core_2.$ctx; } });
|
|
45
|
+
Object.defineProperty(exports, "$debug", { enumerable: true, get: function () { return core_2.$debug; } });
|
|
46
|
+
Object.defineProperty(exports, "createDebug", { enumerable: true, get: function () { return core_2.createDebug; } });
|
|
47
|
+
var body_2 = require("@zenweb/body");
|
|
48
|
+
Object.defineProperty(exports, "Body", { enumerable: true, get: function () { return body_2.Body; } });
|
|
49
|
+
Object.defineProperty(exports, "ObjectBody", { enumerable: true, get: function () { return body_2.ObjectBody; } });
|
|
50
|
+
Object.defineProperty(exports, "BodyHelper", { enumerable: true, get: function () { return body_2.BodyHelper; } });
|
|
51
|
+
Object.defineProperty(exports, "RawBody", { enumerable: true, get: function () { return body_2.RawBody; } });
|
|
52
|
+
Object.defineProperty(exports, "TextBody", { enumerable: true, get: function () { return body_2.TextBody; } });
|
|
53
|
+
Object.defineProperty(exports, "useBodyParser", { enumerable: true, get: function () { return body_2.useBodyParser; } });
|
|
54
|
+
Object.defineProperty(exports, "$body", { enumerable: true, get: function () { return body_2.$body; } });
|
|
55
|
+
Object.defineProperty(exports, "$getTextBody", { enumerable: true, get: function () { return body_2.$getTextBody; } });
|
|
56
|
+
Object.defineProperty(exports, "$getRawBody", { enumerable: true, get: function () { return body_2.$getRawBody; } });
|
|
57
|
+
Object.defineProperty(exports, "$getObjectBody", { enumerable: true, get: function () { return body_2.$getObjectBody; } });
|
|
58
|
+
var helper_2 = require("@zenweb/helper");
|
|
59
|
+
Object.defineProperty(exports, "QueryHelper", { enumerable: true, get: function () { return helper_2.QueryHelper; } });
|
|
60
|
+
Object.defineProperty(exports, "TypeCastHelper", { enumerable: true, get: function () { return helper_2.TypeCastHelper; } });
|
|
61
|
+
Object.defineProperty(exports, "ParamHelper", { enumerable: true, get: function () { return helper_2.ParamHelper; } });
|
|
62
|
+
Object.defineProperty(exports, "$param", { enumerable: true, get: function () { return helper_2.$param; } });
|
|
63
|
+
Object.defineProperty(exports, "$query", { enumerable: true, get: function () { return helper_2.$query; } });
|
|
64
|
+
Object.defineProperty(exports, "$helperBase", { enumerable: true, get: function () { return helper_2.$helperBase; } });
|
|
65
|
+
var log_2 = require("@zenweb/log");
|
|
66
|
+
Object.defineProperty(exports, "$log", { enumerable: true, get: function () { return log_2.$log; } });
|
|
67
|
+
Object.defineProperty(exports, "$getLogger", { enumerable: true, get: function () { return log_2.$getLogger; } });
|
|
20
68
|
/**
|
|
21
69
|
* 创建应用实例
|
|
22
70
|
* @param options 模块配置项
|
|
23
71
|
*/
|
|
24
|
-
|
|
72
|
+
function create(options) {
|
|
25
73
|
options = options || {};
|
|
26
|
-
const core = (options.global !== false) ?
|
|
74
|
+
const core = (options.global !== false) ? (0, core_1.$initCore)(options.core) : new core_1.Core(options.core);
|
|
27
75
|
if (options.meta !== false)
|
|
28
|
-
core.setup(
|
|
76
|
+
core.setup((0, meta_1.default)(options.meta));
|
|
29
77
|
if (options.inject !== false)
|
|
30
|
-
core.setup(
|
|
78
|
+
core.setup((0, inject_1.default)());
|
|
31
79
|
if (options.log !== false)
|
|
32
|
-
core.setup(
|
|
80
|
+
core.setup((0, log_1.default)(options.log));
|
|
33
81
|
if (options.router !== false)
|
|
34
|
-
core.setup(
|
|
82
|
+
core.setup((0, router_1.default)());
|
|
35
83
|
if (options.result !== false)
|
|
36
|
-
core.setup(
|
|
84
|
+
core.setup((0, result_1.default)(options.result));
|
|
37
85
|
if (options.messagecode !== false)
|
|
38
|
-
core.setup(
|
|
86
|
+
core.setup((0, messagecode_1.default)(options.messagecode));
|
|
39
87
|
if (options.helper !== false)
|
|
40
|
-
core.setup(
|
|
88
|
+
core.setup((0, helper_1.default)(options.helper));
|
|
41
89
|
if (options.body !== false)
|
|
42
|
-
core.setup(
|
|
90
|
+
core.setup((0, body_1.default)(options.body));
|
|
43
91
|
if (options.controller !== false)
|
|
44
|
-
core.setup(
|
|
92
|
+
core.setup((0, controller_1.default)(options.controller));
|
|
45
93
|
return core;
|
|
46
94
|
}
|
package/dist/types.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zenweb",
|
|
3
|
-
"
|
|
4
|
-
"version": "6.2.0",
|
|
3
|
+
"version": "6.4.0",
|
|
5
4
|
"description": "Modular lightweight web framework based on Koa",
|
|
6
5
|
"main": "dist/index.js",
|
|
7
6
|
"typings": "./dist/index.d.ts",
|
|
8
7
|
"files": [
|
|
8
|
+
"AGENTS.md",
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"scripts": {
|
|
12
|
-
"build": "rimraf dist && tsc",
|
|
12
|
+
"build": "rimraf dist && tsc -p tsconfig.build.json",
|
|
13
13
|
"prepack": "npm run build",
|
|
14
|
-
"dev": "cd example && node --env-file=.env
|
|
14
|
+
"dev": "cd example && node --env-file=.env -r ts-node/register index.ts"
|
|
15
15
|
},
|
|
16
16
|
"author": {
|
|
17
17
|
"name": "YeFei",
|
|
@@ -28,24 +28,24 @@
|
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"homepage": "https://zenweb.node.ltd",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@zenweb/body": "^5.
|
|
32
|
-
"@zenweb/controller": "^6.
|
|
33
|
-
"@zenweb/core": "^5.
|
|
34
|
-
"@zenweb/helper": "^5.
|
|
35
|
-
"@zenweb/inject": "^5.
|
|
36
|
-
"@zenweb/log": "^5.
|
|
37
|
-
"@zenweb/messagecode": "^5.
|
|
38
|
-
"@zenweb/meta": "^5.
|
|
39
|
-
"@zenweb/result": "^5.
|
|
40
|
-
"@zenweb/router": "^6.
|
|
31
|
+
"@zenweb/body": "^5.4.1",
|
|
32
|
+
"@zenweb/controller": "^6.4.0",
|
|
33
|
+
"@zenweb/core": "^5.3.0",
|
|
34
|
+
"@zenweb/helper": "^5.4.0",
|
|
35
|
+
"@zenweb/inject": "^5.4.0",
|
|
36
|
+
"@zenweb/log": "^5.2.0",
|
|
37
|
+
"@zenweb/messagecode": "^5.5.0",
|
|
38
|
+
"@zenweb/meta": "^5.2.0",
|
|
39
|
+
"@zenweb/result": "^5.3.0",
|
|
40
|
+
"@zenweb/router": "^6.5.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@types/node": "^
|
|
43
|
+
"@types/node": "^16.18.126",
|
|
44
44
|
"rimraf": "^4.4.1",
|
|
45
45
|
"ts-node": "^10.9.2",
|
|
46
|
-
"typescript": "^
|
|
46
|
+
"typescript": "^6.0.3"
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
|
-
"node": ">=
|
|
49
|
+
"node": ">=16"
|
|
50
50
|
}
|
|
51
51
|
}
|