@longzai-intelligence-transport/http-core 0.1.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/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # @longzai-intelligence-transport/http-core
2
+
3
+ HTTP 工具核心模块,提供 API 路由定义、类型推断、响应 Schema、API 函数工厂等共享基础设施。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ bun add @longzai-intelligence-transport/http-core
9
+ ```
10
+
11
+ ## 功能特性
12
+
13
+ - **契约类型定义** - 类型安全的 API 契约定义
14
+ - **通用 Schema** - 基于 Zod 的请求/响应 Schema
15
+ - **路由工具** - API 路由定义和路径参数处理
16
+ - **API 函数工厂** - 创建类型安全的 API 调用函数
17
+ - **HTTP 客户端** - 基于 Axios 的 REST 客户端实现
18
+
19
+ ## 依赖
20
+
21
+ - `axios` - HTTP 客户端
22
+ - `zod` - Schema 验证(peer dependency)
23
+ - `@longzai-intelligence/pagination` - 分页类型
24
+ - `@longzai-intelligence/zod-utils` - Zod 工具函数
25
+
26
+ ## 使用示例
27
+
28
+ ```typescript
29
+ import {
30
+ createHttpClient,
31
+ createApiFunctions,
32
+ defineRoute,
33
+ } from '@longzai-intelligence-transport/http-core';
34
+
35
+ // 定义路由
36
+ const routes = {
37
+ getUser: defineRoute({
38
+ method: 'GET',
39
+ path: '/users/:id',
40
+ response: UserSchema,
41
+ }),
42
+ };
43
+
44
+ // 创建客户端
45
+ const client = createHttpClient({
46
+ baseURL: 'https://api.example.com',
47
+ });
48
+
49
+ // 创建 API 函数
50
+ const api = createApiFunctions(client, routes);
51
+ ```
52
+
53
+ ## 导出模块
54
+
55
+ - `contract` - 契约类型定义
56
+ - `schemas` - 通用 Schema 定义
57
+ - `routes` - 路由工具函数
58
+ - `factory` - API 函数工厂
59
+ - `utils` - 响应工具类
60
+ - `client` - HTTP 客户端实现
61
+
62
+ ## 许可证
63
+
64
+ UNLICENSED