vafast 0.1.1

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.
Files changed (5) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +219 -0
  3. package/dist/index.js +55636 -0
  4. package/dist/main.js +19758 -0
  5. package/package.json +97 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Vafast Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md ADDED
@@ -0,0 +1,219 @@
1
+ # Vafast 🚀
2
+
3
+ > 超高性能的Node.js Web框架,专为Bun运行时设计
4
+
5
+ [![CI](https://github.com/vafast/vafast/workflows/CI/badge.svg)](https://github.com/vafast/vafast/actions)
6
+ [![npm version](https://badge.fury.io/js/vafast.svg)](https://badge.fury.io/js/vafast)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+ [![Bun](https://img.shields.io/badge/Bun-1.0+-FF6B6B?logo=bun)](https://bun.sh/)
9
+
10
+ 一个专注于性能和易用性的现代Node.js Web框架,内置超优化的验证器和中间件系统。
11
+
12
+ ## 🚀 核心特性
13
+
14
+ - **超高性能**: 基于优化的验证器和路由系统
15
+ - **类型安全**: 完整的TypeScript支持
16
+ - **中间件系统**: 灵活可扩展的中间件架构
17
+ - **内置验证**: 超优化的Schema验证器
18
+ - **零依赖**: 最小化外部依赖
19
+
20
+ ## 📦 安装
21
+
22
+ ```bash
23
+ # 使用 bun (推荐)
24
+ bun add vafast
25
+
26
+ # 使用 npm
27
+ npm install vafast
28
+
29
+ # 使用 yarn
30
+ yarn add vafast
31
+ ```
32
+
33
+ ## 🎯 快速开始
34
+
35
+ ### 基础示例
36
+
37
+ ```typescript
38
+ import { createServer, defineRoute } from 'vafast';
39
+ import { Type } from '@sinclair/typebox';
40
+
41
+ // 定义路由Schema
42
+ const userSchema = Type.Object({
43
+ name: Type.String({ minLength: 1 }),
44
+ email: Type.String({ pattern: '^[^@]+@[^@]+\\.[^@]+$' }),
45
+ age: Type.Optional(Type.Number({ minimum: 0 }))
46
+ });
47
+
48
+ // 创建路由
49
+ const userRoute = defineRoute({
50
+ method: 'POST',
51
+ path: '/users',
52
+ body: userSchema,
53
+ handler: async (req) => {
54
+ const { name, email, age } = req.body;
55
+ return { success: true, user: { name, email, age } };
56
+ }
57
+ });
58
+
59
+ // 创建服务器
60
+ const server = createServer();
61
+ server.addRoute(userRoute);
62
+
63
+ server.listen(3000, () => {
64
+ console.log('🚀 服务器运行在 http://localhost:3000');
65
+ });
66
+ ```
67
+
68
+ ### 使用超优化验证器
69
+
70
+ ```typescript
71
+ import { validateAllSchemasExpanded } from 'vafast/utils/validators/validators-ultra';
72
+
73
+ // 定义Schema配置
74
+ const schemaConfig = {
75
+ body: userSchema,
76
+ query: querySchema,
77
+ params: paramsSchema,
78
+ headers: headersSchema,
79
+ cookies: cookiesSchema
80
+ };
81
+
82
+ // 验证请求数据
83
+ const validatedData = validateAllSchemasExpanded(schemaConfig, {
84
+ body: req.body,
85
+ query: req.query,
86
+ params: req.params,
87
+ headers: req.headers,
88
+ cookies: req.cookies
89
+ });
90
+ ```
91
+
92
+ ## 🔧 超优化验证器
93
+
94
+ ### Ultra验证器
95
+
96
+ 我们的旗舰验证器,提供极致性能:
97
+
98
+ - **性能提升**: 相比基础版本提升 **25.7%**
99
+ - **内存优化**: 智能缓存和内存池管理
100
+ - **类型特化**: 针对特定数据类型的优化验证器
101
+ - **批量验证**: 支持数组数据的批量验证
102
+
103
+ ```typescript
104
+ import {
105
+ validateAllSchemasExpanded,
106
+ createTypedValidator,
107
+ validateBatch
108
+ } from 'vafast/utils/validators/validators-ultra';
109
+
110
+ // 创建类型特化验证器
111
+ const userValidator = createTypedValidator(userSchema);
112
+ const validatedUser = userValidator(userData);
113
+
114
+ // 批量验证
115
+ const validatedUsers = validateBatch(userSchema, userArray);
116
+ ```
117
+
118
+ ## 📚 文档
119
+
120
+ - [📖 完整文档](./docs/)
121
+ - [🚀 快速开始](./docs/getting-started/quickstart.md)
122
+ - [🎯 核心功能](./docs/core/)
123
+ - [🔧 高级功能](./docs/advanced/)
124
+ - [📖 API参考](./docs/api/)
125
+ - [🧪 示例代码](./examples/)
126
+
127
+ ## 🧪 测试
128
+
129
+ ```bash
130
+ # 运行所有测试
131
+ bun test
132
+
133
+ # 运行性能测试
134
+ bun run benchmark
135
+
136
+ # 运行特定测试
137
+ bun test:unit # 单元测试
138
+ bun test:integration # 集成测试
139
+ bun test:coverage # 覆盖率测试
140
+
141
+ # 运行基准测试
142
+ bun benchmark:quick # 快速测试
143
+ bun benchmark:validators # 验证器测试
144
+ bun benchmark:ultra # 超性能测试
145
+ bun benchmark:ultimate # 终极性能测试
146
+ bun benchmark:comprehensive # 综合测试
147
+ ```
148
+
149
+ ## 📊 性能基准
150
+
151
+ 基于100,000次迭代的性能测试结果:
152
+
153
+ | 验证器 | 总耗时 | 性能提升 | 稳定性 |
154
+ |--------|--------|----------|---------|
155
+ | **Ultra标准版** | 24.28ms | 基准 | 稳定 |
156
+ | **Ultra展开版** | 23.63ms | **+2.7%** | 稳定 |
157
+
158
+ ## 🤝 贡献
159
+
160
+ 我们欢迎所有形式的贡献!请查看我们的 [贡献指南](./docs/contributing/) 开始参与。
161
+
162
+ ### 快速开始
163
+ 1. [Fork](https://github.com/vafast/vafast/fork) 项目
164
+ 2. 创建功能分支 (`git checkout -b feature/amazing-feature`)
165
+ 3. 提交更改 (`git commit -m 'feat: 添加新功能'`)
166
+ 4. 推送到分支 (`git push origin feature/amazing-feature`)
167
+ 5. 创建 [Pull Request](https://github.com/vafast/vafast/compare)
168
+
169
+ ### 贡献类型
170
+ - 🐛 Bug 修复
171
+ - ✨ 新功能
172
+ - 📚 文档改进
173
+ - 🧪 测试用例
174
+ - 🚀 性能优化
175
+
176
+ ### 社区
177
+ - [Issues](https://github.com/vafast/vafast/issues) - 报告 Bug 或请求功能
178
+ - [Discussions](https://github.com/vafast/vafast/discussions) - 讨论想法和问题
179
+ - [Releases](https://github.com/vafast/vafast/releases) - 查看最新版本
180
+
181
+ ## 📄 许可证
182
+
183
+ MIT License
184
+
185
+ ## 🏆 为什么选择Vafast?
186
+
187
+ 1. **🚀 极致性能**: 超优化的验证器和路由系统
188
+ 2. **🔒 开发体验**: 完整的TypeScript支持和智能提示
189
+ 3. **✅ 生产就绪**: 经过严格测试的稳定版本
190
+ 4. **⚡ 零配置**: 开箱即用的最佳实践配置
191
+ 5. **🔄 活跃维护**: 持续的性能优化和功能更新
192
+
193
+ ## 📊 性能基准
194
+
195
+ 基于100,000次迭代的性能测试结果:
196
+
197
+ | 验证器 | 总耗时 | 性能提升 | 稳定性 |
198
+ |--------|--------|----------|---------|
199
+ | **Ultra标准版** | 24.28ms | 基准 | 稳定 |
200
+ | **Ultra展开版** | 23.63ms | **+2.7%** | 稳定 |
201
+
202
+ ## 🌟 特性亮点
203
+
204
+ - **⚡ 超高性能**: 基于优化的验证器和路由系统
205
+ - **🔒 类型安全**: 完整的TypeScript支持
206
+ - **🧩 中间件系统**: 灵活可扩展的中间件架构
207
+ - **✅ 内置验证**: 超优化的Schema验证器
208
+ - **🎯 零依赖**: 最小化外部依赖
209
+ - **🚀 Bun原生**: 专为Bun运行时优化
210
+
211
+ ---
212
+
213
+ **Vafast** - 让Web开发更快、更安全、更高效! 🚀
214
+
215
+ ## 📄 许可证
216
+
217
+ 本项目采用 [MIT 许可证](./LICENSE)。
218
+
219
+