@kood/claude-code 0.3.6 → 0.3.8
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/dist/index.js +1 -1
- package/package.json +1 -1
- package/templates/.claude/agents/code-reviewer.md +124 -124
- package/templates/.claude/agents/dependency-manager.md +85 -85
- package/templates/.claude/agents/deployment-validator.md +56 -56
- package/templates/.claude/agents/git-operator.md +64 -64
- package/templates/.claude/agents/implementation-executor.md +95 -95
- package/templates/.claude/agents/ko-to-en-translator.md +74 -0
- package/templates/.claude/agents/lint-fixer.md +78 -78
- package/templates/.claude/agents/refactor-advisor.md +122 -122
- package/templates/.claude/commands/agent-creator.md +185 -185
- package/templates/.claude/commands/bug-fix.md +193 -193
- package/templates/.claude/commands/command-creator.md +54 -54
- package/templates/.claude/commands/docs-creator.md +57 -57
- package/templates/.claude/commands/docs-refactor.md +26 -26
- package/templates/.claude/commands/execute.md +12 -12
- package/templates/.claude/commands/git-all.md +32 -32
- package/templates/.claude/commands/git-session.md +42 -42
- package/templates/.claude/commands/git.md +34 -34
- package/templates/.claude/commands/lint-fix.md +138 -138
- package/templates/.claude/commands/lint-init.md +61 -61
- package/templates/.claude/commands/plan.md +260 -260
- package/templates/.claude/commands/prd.md +24 -24
- package/templates/.claude/commands/pre-deploy.md +109 -109
- package/templates/.claude/commands/refactor.md +147 -147
- package/templates/.claude/commands/version-update.md +17 -17
- package/templates/hono/CLAUDE.md +27 -27
- package/templates/hono/docs/architecture.md +24 -24
- package/templates/hono/docs/deployment/cloudflare.md +18 -18
- package/templates/hono/docs/deployment/docker.md +13 -13
- package/templates/hono/docs/deployment/index.md +19 -19
- package/templates/hono/docs/deployment/railway.md +32 -32
- package/templates/hono/docs/deployment/vercel.md +29 -29
- package/templates/hono/docs/guides/conventions.md +57 -57
- package/templates/hono/docs/guides/env-setup.md +47 -47
- package/templates/hono/docs/guides/getting-started.md +27 -27
- package/templates/hono/docs/library/hono/error-handling.md +11 -11
- package/templates/hono/docs/library/hono/index.md +4 -4
- package/templates/hono/docs/library/hono/middleware.md +18 -18
- package/templates/hono/docs/library/hono/rpc.md +7 -7
- package/templates/hono/docs/library/hono/validation.md +6 -6
- package/templates/hono/docs/library/prisma/cloudflare-d1.md +29 -29
- package/templates/hono/docs/library/prisma/config.md +16 -16
- package/templates/hono/docs/library/prisma/index.md +32 -32
- package/templates/hono/docs/library/t3-env/index.md +22 -22
- package/templates/hono/docs/library/zod/index.md +31 -31
- package/templates/nextjs/CLAUDE.md +228 -0
- package/templates/nextjs/docs/design.md +558 -0
- package/templates/nextjs/docs/guides/conventions.md +343 -0
- package/templates/nextjs/docs/guides/getting-started.md +367 -0
- package/templates/nextjs/docs/guides/routes.md +342 -0
- package/templates/nextjs/docs/library/better-auth/index.md +541 -0
- package/templates/nextjs/docs/library/nextjs/app-router.md +269 -0
- package/templates/nextjs/docs/library/nextjs/caching.md +351 -0
- package/templates/nextjs/docs/library/nextjs/index.md +291 -0
- package/templates/nextjs/docs/library/nextjs/middleware.md +391 -0
- package/templates/nextjs/docs/library/nextjs/route-handlers.md +382 -0
- package/templates/nextjs/docs/library/nextjs/server-actions.md +366 -0
- package/templates/nextjs/docs/library/prisma/cloudflare-d1.md +76 -0
- package/templates/nextjs/docs/library/prisma/config.md +77 -0
- package/templates/nextjs/docs/library/prisma/crud.md +90 -0
- package/templates/nextjs/docs/library/prisma/index.md +73 -0
- package/templates/nextjs/docs/library/prisma/relations.md +69 -0
- package/templates/nextjs/docs/library/prisma/schema.md +98 -0
- package/templates/nextjs/docs/library/prisma/setup.md +49 -0
- package/templates/nextjs/docs/library/prisma/transactions.md +50 -0
- package/templates/nextjs/docs/library/tanstack-query/index.md +66 -0
- package/templates/nextjs/docs/library/tanstack-query/invalidation.md +54 -0
- package/templates/nextjs/docs/library/tanstack-query/optimistic-updates.md +77 -0
- package/templates/nextjs/docs/library/tanstack-query/use-mutation.md +63 -0
- package/templates/nextjs/docs/library/tanstack-query/use-query.md +70 -0
- package/templates/nextjs/docs/library/zod/complex-types.md +61 -0
- package/templates/nextjs/docs/library/zod/index.md +56 -0
- package/templates/nextjs/docs/library/zod/transforms.md +51 -0
- package/templates/nextjs/docs/library/zod/validation.md +70 -0
- package/templates/npx/CLAUDE.md +37 -37
- package/templates/npx/docs/library/commander/index.md +12 -12
- package/templates/npx/docs/library/fs-extra/index.md +9 -9
- package/templates/npx/docs/library/prompts/index.md +3 -3
- package/templates/npx/docs/references/patterns.md +12 -12
- package/templates/tanstack-start/CLAUDE.md +53 -49
- package/templates/tanstack-start/docs/architecture.md +128 -128
- package/templates/tanstack-start/docs/design.md +169 -169
- package/templates/tanstack-start/docs/guides/conventions.md +43 -43
- package/templates/tanstack-start/docs/guides/env-setup.md +35 -35
- package/templates/tanstack-start/docs/guides/getting-started.md +19 -19
- package/templates/tanstack-start/docs/guides/hooks.md +63 -35
- package/templates/tanstack-start/docs/guides/routes.md +61 -42
- package/templates/tanstack-start/docs/guides/services.md +45 -45
- package/templates/tanstack-start/docs/library/better-auth/index.md +68 -68
- package/templates/tanstack-start/docs/library/prisma/cloudflare-d1.md +19 -19
- package/templates/tanstack-start/docs/library/prisma/config.md +16 -16
- package/templates/tanstack-start/docs/library/prisma/crud.md +17 -17
- package/templates/tanstack-start/docs/library/prisma/index.md +17 -17
- package/templates/tanstack-start/docs/library/prisma/relations.md +16 -16
- package/templates/tanstack-start/docs/library/prisma/schema.md +23 -23
- package/templates/tanstack-start/docs/library/prisma/setup.md +6 -6
- package/templates/tanstack-start/docs/library/prisma/transactions.md +10 -10
- package/templates/tanstack-start/docs/library/t3-env/index.md +21 -160
- package/templates/tanstack-start/docs/library/tanstack-query/index.md +6 -6
- package/templates/tanstack-start/docs/library/tanstack-query/invalidation.md +19 -19
- package/templates/tanstack-start/docs/library/tanstack-query/optimistic-updates.md +4 -4
- package/templates/tanstack-start/docs/library/tanstack-query/use-mutation.md +14 -14
- package/templates/tanstack-start/docs/library/tanstack-query/use-query.md +21 -21
- package/templates/tanstack-start/docs/library/tanstack-router/error-handling.md +9 -9
- package/templates/tanstack-start/docs/library/tanstack-router/hooks.md +11 -11
- package/templates/tanstack-start/docs/library/tanstack-router/index.md +18 -18
- package/templates/tanstack-start/docs/library/tanstack-router/navigation.md +17 -17
- package/templates/tanstack-start/docs/library/tanstack-router/route-context.md +5 -5
- package/templates/tanstack-start/docs/library/tanstack-router/search-params.md +10 -10
- package/templates/tanstack-start/docs/library/tanstack-start/auth-patterns.md +8 -8
- package/templates/tanstack-start/docs/library/tanstack-start/index.md +15 -15
- package/templates/tanstack-start/docs/library/tanstack-start/middleware.md +9 -9
- package/templates/tanstack-start/docs/library/tanstack-start/routing.md +6 -6
- package/templates/tanstack-start/docs/library/tanstack-start/server-functions.md +18 -18
- package/templates/tanstack-start/docs/library/tanstack-start/setup.md +4 -4
- package/templates/tanstack-start/docs/library/zod/complex-types.md +11 -11
- package/templates/tanstack-start/docs/library/zod/index.md +8 -8
- package/templates/tanstack-start/docs/library/zod/transforms.md +11 -11
- package/templates/tanstack-start/docs/library/zod/validation.md +9 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Route Structure
|
|
2
2
|
|
|
3
|
-
> TanStack Start
|
|
3
|
+
> TanStack Start File-Based Routing
|
|
4
4
|
|
|
5
5
|
<instructions>
|
|
6
6
|
@../library/tanstack-router/index.md
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
<route_structure>
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Route Folder Structure
|
|
14
14
|
|
|
15
15
|
```
|
|
16
16
|
routes/
|
|
@@ -19,19 +19,28 @@ routes/
|
|
|
19
19
|
├── users/
|
|
20
20
|
│ ├── index.tsx # /users (List)
|
|
21
21
|
│ ├── $id.tsx # /users/:id (Detail)
|
|
22
|
-
│ ├── -components/ #
|
|
23
|
-
│ ├── -
|
|
24
|
-
│
|
|
22
|
+
│ ├── -components/ # Page-specific components (required)
|
|
23
|
+
│ ├── -hooks/ # Page-specific Hooks (required)
|
|
24
|
+
│ ├── -functions/ # Page-specific Server Functions (required)
|
|
25
|
+
│ └── -sections/ # Section separation (optional, complex pages only)
|
|
25
26
|
└── posts/
|
|
26
27
|
├── index.tsx
|
|
27
|
-
|
|
28
|
+
├── $slug.tsx
|
|
29
|
+
├── -components/ # Required
|
|
30
|
+
├── -hooks/ # Required
|
|
31
|
+
└── -functions/ # Required
|
|
28
32
|
```
|
|
29
33
|
|
|
30
|
-
|
|
|
31
|
-
|
|
32
|
-
| `-` |
|
|
33
|
-
| `$` |
|
|
34
|
-
| `_` | Pathless Layout | ✅
|
|
34
|
+
| Prefix | Purpose | Route Generation |
|
|
35
|
+
|--------|---------|------------------|
|
|
36
|
+
| `-` | Exclude from routes | ❌ Excluded |
|
|
37
|
+
| `$` | Dynamic parameters | ✅ Generated |
|
|
38
|
+
| `_` | Pathless Layout | ✅ Generated (no path) |
|
|
39
|
+
|
|
40
|
+
**⚠️ Required Rules:**
|
|
41
|
+
- All pages must have `-components/`, `-hooks/`, `-functions/` folders
|
|
42
|
+
- Custom Hooks must always be separated into `-hooks/` folder regardless of page size
|
|
43
|
+
- `-sections/` is optional, use only for complex pages (200+ lines)
|
|
35
44
|
|
|
36
45
|
</route_structure>
|
|
37
46
|
|
|
@@ -39,17 +48,17 @@ routes/
|
|
|
39
48
|
|
|
40
49
|
<file_naming>
|
|
41
50
|
|
|
42
|
-
##
|
|
51
|
+
## Route File Naming Rules
|
|
43
52
|
|
|
44
|
-
|
|
|
45
|
-
|
|
46
|
-
| `/` | `index.tsx` |
|
|
47
|
-
| `/users` | `users/index.tsx` |
|
|
48
|
-
| `/users/:id` | `users/$id.tsx` |
|
|
49
|
-
| `/posts/:slug` | `posts/$slug.tsx` | URL
|
|
50
|
-
| `/dashboard/*` | `dashboard/$.tsx` | Catch-all
|
|
51
|
-
| Layout | `__root.tsx` | Root
|
|
52
|
-
| Pathless | `_layout.tsx` |
|
|
53
|
+
| Path | Filename | Description |
|
|
54
|
+
|------|----------|-------------|
|
|
55
|
+
| `/` | `index.tsx` | Index route |
|
|
56
|
+
| `/users` | `users/index.tsx` | List page |
|
|
57
|
+
| `/users/:id` | `users/$id.tsx` | Dynamic parameter |
|
|
58
|
+
| `/posts/:slug` | `posts/$slug.tsx` | URL parameter |
|
|
59
|
+
| `/dashboard/*` | `dashboard/$.tsx` | Catch-all route |
|
|
60
|
+
| Layout | `__root.tsx` | Root layout |
|
|
61
|
+
| Pathless | `_layout.tsx` | Pathless layout |
|
|
53
62
|
|
|
54
63
|
</file_naming>
|
|
55
64
|
|
|
@@ -57,7 +66,7 @@ routes/
|
|
|
57
66
|
|
|
58
67
|
<patterns>
|
|
59
68
|
|
|
60
|
-
##
|
|
69
|
+
## Basic Route Pattern
|
|
61
70
|
|
|
62
71
|
```tsx
|
|
63
72
|
// routes/users/index.tsx
|
|
@@ -80,7 +89,7 @@ const UsersPage = (): JSX.Element => {
|
|
|
80
89
|
}
|
|
81
90
|
```
|
|
82
91
|
|
|
83
|
-
##
|
|
92
|
+
## Dynamic Route + Loader
|
|
84
93
|
|
|
85
94
|
```tsx
|
|
86
95
|
// routes/users/$id.tsx
|
|
@@ -179,7 +188,7 @@ const DashboardPage = (): JSX.Element => {
|
|
|
179
188
|
}
|
|
180
189
|
```
|
|
181
190
|
|
|
182
|
-
## Section
|
|
191
|
+
## Section Pattern
|
|
183
192
|
|
|
184
193
|
```tsx
|
|
185
194
|
// routes/users/-sections/user-list-section.tsx
|
|
@@ -208,7 +217,7 @@ export const UserListSection = (): JSX.Element => {
|
|
|
208
217
|
}
|
|
209
218
|
```
|
|
210
219
|
|
|
211
|
-
##
|
|
220
|
+
## Component Pattern
|
|
212
221
|
|
|
213
222
|
```tsx
|
|
214
223
|
// routes/users/-components/user-card.tsx
|
|
@@ -257,37 +266,47 @@ export const UserCard = ({
|
|
|
257
266
|
|
|
258
267
|
---
|
|
259
268
|
|
|
260
|
-
<
|
|
269
|
+
<folder_structure_rules>
|
|
270
|
+
|
|
271
|
+
## Folder Structure Rules
|
|
272
|
+
|
|
273
|
+
**⚠️ Required for All Pages:**
|
|
274
|
+
- `-components/`: Page-specific components
|
|
275
|
+
- `-hooks/`: Page-specific Custom Hooks (regardless of line count)
|
|
276
|
+
- `-functions/`: Page-specific Server Functions
|
|
277
|
+
|
|
278
|
+
**Optional:**
|
|
279
|
+
- `-sections/`: Use only for complex pages (200+ lines)
|
|
261
280
|
|
|
262
|
-
|
|
|
263
|
-
|
|
264
|
-
| ~100
|
|
265
|
-
| 100-200
|
|
266
|
-
| 200
|
|
281
|
+
| Page Size | Required | Optional |
|
|
282
|
+
|-----------|----------|----------|
|
|
283
|
+
| ~100 lines | `-components/`, `-hooks/`, `-functions/` | - |
|
|
284
|
+
| 100-200 lines | `-components/`, `-hooks/`, `-functions/` | - |
|
|
285
|
+
| 200+ lines | `-components/`, `-hooks/`, `-functions/` | `-sections/` |
|
|
267
286
|
|
|
268
|
-
</
|
|
287
|
+
</folder_structure_rules>
|
|
269
288
|
|
|
270
289
|
---
|
|
271
290
|
|
|
272
291
|
<loader_execution>
|
|
273
292
|
|
|
274
|
-
## Loader
|
|
293
|
+
## Loader Execution Order
|
|
275
294
|
|
|
276
|
-
|
|
|
277
|
-
|
|
278
|
-
| 1. `beforeLoad` |
|
|
279
|
-
| 2. `loader` |
|
|
295
|
+
| Step | Execution | Description |
|
|
296
|
+
|------|-----------|-------------|
|
|
297
|
+
| 1. `beforeLoad` | Sequential (outermost → innermost) | Auth check, context setup |
|
|
298
|
+
| 2. `loader` | Parallel (all loaders simultaneously) | Data fetching |
|
|
280
299
|
|
|
281
300
|
```tsx
|
|
282
301
|
// Parent Route
|
|
283
302
|
export const Route = createFileRoute('/dashboard')({
|
|
284
303
|
beforeLoad: async () => {
|
|
285
|
-
// 1.
|
|
304
|
+
// 1. Runs first (sequential)
|
|
286
305
|
const auth = await checkAuth()
|
|
287
306
|
return { auth }
|
|
288
307
|
},
|
|
289
308
|
loader: async () => {
|
|
290
|
-
// 2.
|
|
309
|
+
// 2. Runs later (parallel)
|
|
291
310
|
return getDashboardData()
|
|
292
311
|
},
|
|
293
312
|
})
|
|
@@ -295,11 +314,11 @@ export const Route = createFileRoute('/dashboard')({
|
|
|
295
314
|
// Child Route
|
|
296
315
|
export const Route = createFileRoute('/dashboard/users')({
|
|
297
316
|
beforeLoad: async () => {
|
|
298
|
-
// 1. Parent beforeLoad
|
|
317
|
+
// 1. Runs after Parent beforeLoad
|
|
299
318
|
return {}
|
|
300
319
|
},
|
|
301
320
|
loader: async () => {
|
|
302
|
-
// 2. Parent loader
|
|
321
|
+
// 2. Runs in parallel with Parent loader
|
|
303
322
|
return getUsers()
|
|
304
323
|
},
|
|
305
324
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Server Functions
|
|
2
2
|
|
|
3
|
-
> TanStack Start
|
|
3
|
+
> TanStack Start Data Layer (Server Functions)
|
|
4
4
|
|
|
5
5
|
<instructions>
|
|
6
6
|
@../library/tanstack-start/index.md
|
|
@@ -10,15 +10,15 @@
|
|
|
10
10
|
|
|
11
11
|
<api_naming>
|
|
12
12
|
|
|
13
|
-
## API
|
|
13
|
+
## API Names (Important)
|
|
14
14
|
|
|
15
|
-
| ✅
|
|
16
|
-
|
|
17
|
-
| `.inputValidator()` | ~~`.validator()`~~ | TanStack Start
|
|
18
|
-
| `.middleware()` | - | Middleware
|
|
19
|
-
| `.handler()` | - |
|
|
15
|
+
| ✅ Correct API | ❌ Incorrect API | Description |
|
|
16
|
+
|----------------|------------------|-------------|
|
|
17
|
+
| `.inputValidator()` | ~~`.validator()`~~ | TanStack Start only supports `inputValidator` |
|
|
18
|
+
| `.middleware()` | - | Middleware chaining |
|
|
19
|
+
| `.handler()` | - | Final handler function |
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
**Note:** `validator` does not exist. Always use `inputValidator`.
|
|
22
22
|
|
|
23
23
|
</api_naming>
|
|
24
24
|
|
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
|
|
27
27
|
<folder_structure>
|
|
28
28
|
|
|
29
|
-
##
|
|
29
|
+
## Service Folder Structure
|
|
30
30
|
|
|
31
31
|
```
|
|
32
32
|
services/
|
|
33
33
|
├── user/
|
|
34
|
-
│ ├── index.ts #
|
|
35
|
-
│ ├── schemas.ts # Zod
|
|
36
|
-
│ ├── queries.ts # GET (
|
|
37
|
-
│ └── mutations.ts # POST (
|
|
34
|
+
│ ├── index.ts # Entry point (re-export)
|
|
35
|
+
│ ├── schemas.ts # Zod schemas
|
|
36
|
+
│ ├── queries.ts # GET (read)
|
|
37
|
+
│ └── mutations.ts # POST (write)
|
|
38
38
|
├── auth/
|
|
39
39
|
│ ├── index.ts
|
|
40
40
|
│ ├── schemas.ts
|
|
@@ -47,12 +47,12 @@ services/
|
|
|
47
47
|
└── mutations.ts
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
|
|
|
51
|
-
|
|
52
|
-
| `index.ts` |
|
|
53
|
-
| `schemas.ts` | Zod
|
|
54
|
-
| `queries.ts` | GET
|
|
55
|
-
| `mutations.ts` | POST/PUT/DELETE (
|
|
50
|
+
| File | Purpose |
|
|
51
|
+
|------|---------|
|
|
52
|
+
| `index.ts` | Re-export all functions |
|
|
53
|
+
| `schemas.ts` | Zod validation schemas |
|
|
54
|
+
| `queries.ts` | GET requests (read) |
|
|
55
|
+
| `mutations.ts` | POST/PUT/DELETE (write) |
|
|
56
56
|
|
|
57
57
|
</folder_structure>
|
|
58
58
|
|
|
@@ -60,7 +60,7 @@ services/
|
|
|
60
60
|
|
|
61
61
|
<patterns>
|
|
62
62
|
|
|
63
|
-
## Schemas
|
|
63
|
+
## Schemas File
|
|
64
64
|
|
|
65
65
|
```typescript
|
|
66
66
|
// services/user/schemas.ts
|
|
@@ -81,7 +81,7 @@ export type CreateUserInput = z.infer<typeof createUserSchema>
|
|
|
81
81
|
export type UpdateUserInput = z.infer<typeof updateUserSchema>
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
-
## Queries
|
|
84
|
+
## Queries File (GET)
|
|
85
85
|
|
|
86
86
|
```typescript
|
|
87
87
|
// services/user/queries.ts
|
|
@@ -108,7 +108,7 @@ export const getUserByEmail = createServerFn({ method: 'GET' })
|
|
|
108
108
|
})
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
-
## Mutations
|
|
111
|
+
## Mutations File (POST)
|
|
112
112
|
|
|
113
113
|
```typescript
|
|
114
114
|
// services/user/mutations.ts
|
|
@@ -135,7 +135,7 @@ export const deleteUser = createServerFn({ method: 'POST' })
|
|
|
135
135
|
})
|
|
136
136
|
```
|
|
137
137
|
|
|
138
|
-
##
|
|
138
|
+
## Entry Point File
|
|
139
139
|
|
|
140
140
|
```typescript
|
|
141
141
|
// services/user/index.ts
|
|
@@ -144,7 +144,7 @@ export * from './queries'
|
|
|
144
144
|
export * from './mutations'
|
|
145
145
|
```
|
|
146
146
|
|
|
147
|
-
## Database
|
|
147
|
+
## Database File
|
|
148
148
|
|
|
149
149
|
```typescript
|
|
150
150
|
// database/prisma.ts
|
|
@@ -171,7 +171,7 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
171
171
|
|
|
172
172
|
<middleware>
|
|
173
173
|
|
|
174
|
-
## Middleware
|
|
174
|
+
## Middleware Pattern
|
|
175
175
|
|
|
176
176
|
```typescript
|
|
177
177
|
// middleware/auth.ts
|
|
@@ -234,7 +234,7 @@ export const deleteUser = createServerFn({ method: 'POST' })
|
|
|
234
234
|
|
|
235
235
|
<usage>
|
|
236
236
|
|
|
237
|
-
## TanStack Query
|
|
237
|
+
## TanStack Query Integration
|
|
238
238
|
|
|
239
239
|
```typescript
|
|
240
240
|
// routes/users/-hooks/use-users.ts
|
|
@@ -274,7 +274,7 @@ export const useUsers = () => {
|
|
|
274
274
|
}
|
|
275
275
|
```
|
|
276
276
|
|
|
277
|
-
## Form
|
|
277
|
+
## Form Integration
|
|
278
278
|
|
|
279
279
|
```tsx
|
|
280
280
|
// routes/users/-components/create-user-form.tsx
|
|
@@ -331,23 +331,23 @@ export const CreateUserForm = (): JSX.Element => {
|
|
|
331
331
|
|
|
332
332
|
<method_chaining>
|
|
333
333
|
|
|
334
|
-
## Method Chaining
|
|
334
|
+
## Method Chaining Order
|
|
335
335
|
|
|
336
336
|
```typescript
|
|
337
|
-
// ✅
|
|
337
|
+
// ✅ Correct order
|
|
338
338
|
createServerFn({ method: 'POST' })
|
|
339
|
-
.middleware([authMiddleware]) // 1. middleware (
|
|
340
|
-
.inputValidator(createUserSchema) // 2. inputValidator (
|
|
341
|
-
.handler(async ({ data }) => {}) // 3. handler (
|
|
339
|
+
.middleware([authMiddleware]) // 1. middleware (optional)
|
|
340
|
+
.inputValidator(createUserSchema) // 2. inputValidator (optional)
|
|
341
|
+
.handler(async ({ data }) => {}) // 3. handler (required)
|
|
342
342
|
|
|
343
|
-
// ❌
|
|
343
|
+
// ❌ Wrong order (TypeScript error)
|
|
344
344
|
createServerFn({ method: 'POST' })
|
|
345
|
-
.handler(async () => {}) // ❌ handler
|
|
346
|
-
.inputValidator(schema) // ❌ inputValidator
|
|
345
|
+
.handler(async () => {}) // ❌ handler first
|
|
346
|
+
.inputValidator(schema) // ❌ inputValidator after
|
|
347
347
|
|
|
348
|
-
// ❌
|
|
348
|
+
// ❌ Wrong API name (does not exist)
|
|
349
349
|
createServerFn({ method: 'POST' })
|
|
350
|
-
.validator(schema) // ❌ validator
|
|
350
|
+
.validator(schema) // ❌ validator doesn't exist! Use inputValidator
|
|
351
351
|
.handler(async ({ data }) => {})
|
|
352
352
|
```
|
|
353
353
|
|
|
@@ -357,14 +357,14 @@ createServerFn({ method: 'POST' })
|
|
|
357
357
|
|
|
358
358
|
<best_practices>
|
|
359
359
|
|
|
360
|
-
|
|
|
361
|
-
|
|
362
|
-
|
|
|
363
|
-
|
|
|
364
|
-
| **Validation** | POST/PUT/DELETE
|
|
365
|
-
| **Middleware** |
|
|
366
|
-
| **TanStack Query** |
|
|
367
|
-
|
|
|
360
|
+
| Principle | Description |
|
|
361
|
+
|-----------|-------------|
|
|
362
|
+
| **File Separation** | Separate schemas, queries, mutations required |
|
|
363
|
+
| **Entry Point** | Re-export all functions in index.ts |
|
|
364
|
+
| **Validation** | inputValidator required for POST/PUT/DELETE |
|
|
365
|
+
| **Middleware** | Use middleware for auth/permissions |
|
|
366
|
+
| **TanStack Query** | Never call directly from client, use Query/Mutation |
|
|
367
|
+
| **Error Handling** | Throw clear error messages |
|
|
368
368
|
|
|
369
369
|
</best_practices>
|
|
370
370
|
|