- 新增 Dockerfile 和 .dockerignore 文件 - 添加 Gitea 持续集成工作流,用于构建和推送 Docker 镜像 - 新增 .gitignore 文件,忽略构建和配置文件 - 添加项目结构和规范文档,包括 TypeScript、模块化、API、数据库等规范 - 新增前端和后端的基础代码结构
1.1 KiB
1.1 KiB
RPC 调用规范
核心原则
-
类型安全:
- 所有RPC调用必须基于OpenAPI定义的类型
- 客户端和服务端类型必须严格匹配
-
一致性:
- RPC调用路径必须与OpenAPI路由定义一致
- 错误处理格式必须统一
-
api版本:
- 所有RPC调用必须基于OpenAPI定义的版本
- 版本号必须与OpenAPI版本号一致 目前仅支持v1版本 示例:
import { client } from '@/client/editor/api'; client.api.v1
客户端规范
1. 客户端初始化
import { hc } from 'hono/client'
import ApiRoutes from '@/server/api';
export const client = hc<typeof ApiRoutes>('/', {
fetch: axiosFetch,
});
2. 方法调用
- 必须使用解构方式组织RPC方法
- 方法命名必须与OpenAPI路由定义一致
- 示例:
const res = await client.api.v1.workspaces.templates.blank[':templateType'].$get({
param: {
templateType
}
});
if (res.status !== 200) {
throw new Error(res.message);
}
const templateInfo = await res.json();