@lark-apaas/coding-templates 0.1.35-alpha.2 → 0.1.36
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/package.json
CHANGED
package/template-apex/README.md
CHANGED
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
|
|
20
20
|
```
|
|
21
21
|
├── client/src/ # 前端代码
|
|
22
|
-
│ ├──
|
|
22
|
+
│ ├── main.tsx # 入口(Provider 层级 + 样式引入,勿修改)
|
|
23
|
+
│ ├── app.tsx # 路由配置
|
|
23
24
|
│ ├── index.css # 全局样式 + 主题变量
|
|
24
25
|
│ ├── api/ # API 请求封装
|
|
25
26
|
│ │ └── index.ts
|
|
@@ -34,12 +35,12 @@
|
|
|
34
35
|
│ ├── hooks/ # 自定义 Hooks
|
|
35
36
|
│ └── lib/ # 工具函数(cn() 等)
|
|
36
37
|
├── server/ # 后端代码
|
|
37
|
-
│ ├── index.ts # Express
|
|
38
|
-
│ ├── routes/ #
|
|
39
|
-
│ │
|
|
38
|
+
│ ├── index.ts # Express 入口
|
|
39
|
+
│ ├── routes/ # 路由
|
|
40
|
+
│ │ ├── index.ts # 路由注册
|
|
41
|
+
│ │ └── view.ts # 页面渲染(catch-all HTML 响应,勿修改)
|
|
40
42
|
│ └── db/ # 数据库层
|
|
41
|
-
│ ├── schema.ts # Drizzle schema
|
|
42
|
-
│ └── index.ts # 数据库连接
|
|
43
|
+
│ ├── schema.ts # Drizzle schema 定义(工具自动生成,勿手动修改)
|
|
43
44
|
├── shared/ # 前后端共享(不依赖 client 或 server)
|
|
44
45
|
│ ├── types.ts # 数据模型类型
|
|
45
46
|
│ └── api.interface.ts # zod schema + API 入参/出参类型
|
|
@@ -76,7 +77,7 @@ export type ListPostsResponse = Post[];
|
|
|
76
77
|
|
|
77
78
|
### 2. server/ — 数据库和路由
|
|
78
79
|
|
|
79
|
-
`server/db/schema.ts`
|
|
80
|
+
`server/db/schema.ts` 由 `npm run gen:db-schema` 自动生成,无需手动编写。运行命令后会根据数据库表结构自动生成如下定义:
|
|
80
81
|
|
|
81
82
|
```typescript
|
|
82
83
|
export const posts = pgTable("posts", {
|
|
@@ -91,7 +92,7 @@ export const posts = pgTable("posts", {
|
|
|
91
92
|
|
|
92
93
|
```typescript
|
|
93
94
|
import { Router } from "express";
|
|
94
|
-
import { db } from "
|
|
95
|
+
import { db } from "@lark-apaas/express-core";
|
|
95
96
|
import { posts } from "../db/schema";
|
|
96
97
|
import { createPostSchema } from "@shared/api.interface";
|
|
97
98
|
|
|
@@ -120,11 +121,12 @@ app.use("/api/posts", postsRouter);
|
|
|
120
121
|
|
|
121
122
|
> ⚠️ **客户端所有 HTTP 请求必须使用 `axiosForBackend`**
|
|
122
123
|
>
|
|
123
|
-
> `axiosForBackend` 由 `@lark-apaas/client-toolkit-lite`
|
|
124
|
+
> `axiosForBackend` 由 `@lark-apaas/client-toolkit-lite` 提供,内置平台鉴权、CSRF token 注入和请求上下文。**禁止使用** `fetch`、`axios`、`XMLHttpRequest` 或其他 HTTP 客户端直接发起请求。
|
|
124
125
|
|
|
125
126
|
`client/src/api/index.ts` 增加封装:
|
|
126
127
|
|
|
127
128
|
```typescript
|
|
129
|
+
import { axiosForBackend } from "@lark-apaas/client-toolkit-lite";
|
|
128
130
|
import type { ListPostsResponse } from "@shared/api.interface";
|
|
129
131
|
|
|
130
132
|
export async function listPosts(): Promise<ListPostsResponse> {
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"@radix-ui/react-toggle": "^1.1.9",
|
|
49
49
|
"@radix-ui/react-toggle-group": "^1.1.10",
|
|
50
50
|
"@radix-ui/react-tooltip": "^1.1.18",
|
|
51
|
-
"@lark-apaas/client-toolkit-lite": "^1.1.0
|
|
52
|
-
"@lark-apaas/express-core": "^
|
|
51
|
+
"@lark-apaas/client-toolkit-lite": "^1.1.0",
|
|
52
|
+
"@lark-apaas/express-core": "^1.0.0",
|
|
53
53
|
"@formkit/auto-animate": "^0.9.0",
|
|
54
54
|
"framer-motion": "^12.38.0",
|
|
55
55
|
"class-variance-authority": "^0.7.1",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"zod": "^4.3.6"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@lark-apaas/coding-presets": "^1.0.
|
|
83
|
+
"@lark-apaas/coding-presets": "^1.0.0",
|
|
84
84
|
"@lark-apaas/coding-vite-preset": "^1.0.0",
|
|
85
85
|
"@vercel/nft": "^0.29.2",
|
|
86
86
|
"@types/express": "^5",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@radix-ui/react-toggle": "^1.1.9",
|
|
44
44
|
"@radix-ui/react-toggle-group": "^1.1.10",
|
|
45
45
|
"@radix-ui/react-tooltip": "^1.1.18",
|
|
46
|
-
"@lark-apaas/client-toolkit-lite": "^1.1.0
|
|
46
|
+
"@lark-apaas/client-toolkit-lite": "^1.1.0",
|
|
47
47
|
"@formkit/auto-animate": "^0.9.0",
|
|
48
48
|
"framer-motion": "^12.38.0",
|
|
49
49
|
"class-variance-authority": "^0.7.1",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@types/node": "^24",
|
|
76
76
|
"@types/react": "^19",
|
|
77
77
|
"@types/react-dom": "^19",
|
|
78
|
-
"@lark-apaas/coding-presets": "^1.0.
|
|
78
|
+
"@lark-apaas/coding-presets": "^1.0.0",
|
|
79
79
|
"@lark-apaas/coding-vite-preset": "^1.0.0",
|
|
80
80
|
"concurrently": "^9",
|
|
81
81
|
"eslint": "^9",
|