@kood/claude-code 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.
Files changed (78) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +297 -0
  3. package/package.json +47 -0
  4. package/templates/hono/CLAUDE.md +376 -0
  5. package/templates/hono/docs/deployment/cloudflare.md +328 -0
  6. package/templates/hono/docs/deployment/index.md +291 -0
  7. package/templates/hono/docs/git/index.md +180 -0
  8. package/templates/hono/docs/library/hono/error-handling.md +400 -0
  9. package/templates/hono/docs/library/hono/index.md +241 -0
  10. package/templates/hono/docs/library/hono/middleware.md +334 -0
  11. package/templates/hono/docs/library/hono/rpc.md +454 -0
  12. package/templates/hono/docs/library/hono/validation.md +328 -0
  13. package/templates/hono/docs/library/prisma/index.md +427 -0
  14. package/templates/hono/docs/library/zod/index.md +413 -0
  15. package/templates/hono/docs/mcp/context7.md +106 -0
  16. package/templates/hono/docs/mcp/index.md +94 -0
  17. package/templates/hono/docs/mcp/sequential-thinking.md +101 -0
  18. package/templates/hono/docs/mcp/sgrep.md +105 -0
  19. package/templates/hono/docs/skills/gemini-review/SKILL.md +220 -0
  20. package/templates/hono/docs/skills/gemini-review/references/checklists.md +136 -0
  21. package/templates/hono/docs/skills/gemini-review/references/prompt-templates.md +303 -0
  22. package/templates/tanstack-start/CLAUDE.md +279 -0
  23. package/templates/tanstack-start/docs/architecture/architecture.md +547 -0
  24. package/templates/tanstack-start/docs/deployment/cloudflare.md +346 -0
  25. package/templates/tanstack-start/docs/deployment/index.md +102 -0
  26. package/templates/tanstack-start/docs/deployment/nitro.md +211 -0
  27. package/templates/tanstack-start/docs/deployment/railway.md +364 -0
  28. package/templates/tanstack-start/docs/deployment/vercel.md +287 -0
  29. package/templates/tanstack-start/docs/design/accessibility.md +433 -0
  30. package/templates/tanstack-start/docs/design/color.md +235 -0
  31. package/templates/tanstack-start/docs/design/components.md +409 -0
  32. package/templates/tanstack-start/docs/design/index.md +107 -0
  33. package/templates/tanstack-start/docs/design/safe-area.md +317 -0
  34. package/templates/tanstack-start/docs/design/spacing.md +341 -0
  35. package/templates/tanstack-start/docs/design/tailwind-setup.md +470 -0
  36. package/templates/tanstack-start/docs/design/typography.md +324 -0
  37. package/templates/tanstack-start/docs/git/index.md +203 -0
  38. package/templates/tanstack-start/docs/guides/best-practices.md +753 -0
  39. package/templates/tanstack-start/docs/guides/getting-started.md +304 -0
  40. package/templates/tanstack-start/docs/guides/husky-lint-staged.md +303 -0
  41. package/templates/tanstack-start/docs/guides/prettier.md +189 -0
  42. package/templates/tanstack-start/docs/guides/project-templates.md +710 -0
  43. package/templates/tanstack-start/docs/library/better-auth/2fa.md +136 -0
  44. package/templates/tanstack-start/docs/library/better-auth/advanced.md +138 -0
  45. package/templates/tanstack-start/docs/library/better-auth/index.md +83 -0
  46. package/templates/tanstack-start/docs/library/better-auth/plugins.md +111 -0
  47. package/templates/tanstack-start/docs/library/better-auth/session.md +127 -0
  48. package/templates/tanstack-start/docs/library/better-auth/setup.md +123 -0
  49. package/templates/tanstack-start/docs/library/prisma/crud.md +218 -0
  50. package/templates/tanstack-start/docs/library/prisma/index.md +165 -0
  51. package/templates/tanstack-start/docs/library/prisma/relations.md +191 -0
  52. package/templates/tanstack-start/docs/library/prisma/schema.md +177 -0
  53. package/templates/tanstack-start/docs/library/prisma/setup.md +156 -0
  54. package/templates/tanstack-start/docs/library/prisma/transactions.md +140 -0
  55. package/templates/tanstack-start/docs/library/tanstack-query/index.md +146 -0
  56. package/templates/tanstack-start/docs/library/tanstack-query/invalidation.md +146 -0
  57. package/templates/tanstack-start/docs/library/tanstack-query/optimistic-updates.md +196 -0
  58. package/templates/tanstack-start/docs/library/tanstack-query/setup.md +110 -0
  59. package/templates/tanstack-start/docs/library/tanstack-query/use-mutation.md +170 -0
  60. package/templates/tanstack-start/docs/library/tanstack-query/use-query.md +173 -0
  61. package/templates/tanstack-start/docs/library/tanstack-start/auth-patterns.md +171 -0
  62. package/templates/tanstack-start/docs/library/tanstack-start/index.md +114 -0
  63. package/templates/tanstack-start/docs/library/tanstack-start/middleware.md +142 -0
  64. package/templates/tanstack-start/docs/library/tanstack-start/routing.md +163 -0
  65. package/templates/tanstack-start/docs/library/tanstack-start/server-functions.md +128 -0
  66. package/templates/tanstack-start/docs/library/tanstack-start/setup.md +85 -0
  67. package/templates/tanstack-start/docs/library/zod/basic-types.md +186 -0
  68. package/templates/tanstack-start/docs/library/zod/complex-types.md +204 -0
  69. package/templates/tanstack-start/docs/library/zod/index.md +186 -0
  70. package/templates/tanstack-start/docs/library/zod/transforms.md +174 -0
  71. package/templates/tanstack-start/docs/library/zod/validation.md +208 -0
  72. package/templates/tanstack-start/docs/mcp/context7.md +204 -0
  73. package/templates/tanstack-start/docs/mcp/index.md +116 -0
  74. package/templates/tanstack-start/docs/mcp/sequential-thinking.md +180 -0
  75. package/templates/tanstack-start/docs/mcp/sgrep.md +174 -0
  76. package/templates/tanstack-start/docs/skills/gemini-review/SKILL.md +220 -0
  77. package/templates/tanstack-start/docs/skills/gemini-review/references/checklists.md +150 -0
  78. package/templates/tanstack-start/docs/skills/gemini-review/references/prompt-templates.md +293 -0
@@ -0,0 +1,454 @@
1
+ # Hono RPC Client
2
+
3
+ > Type-safe API 호출을 위한 RPC 클라이언트
4
+
5
+ ---
6
+
7
+ ## 개요
8
+
9
+ Hono의 RPC 기능은 서버 타입을 클라이언트에서 직접 사용하여 타입 안전한 API 호출을 가능하게 합니다.
10
+
11
+ ---
12
+
13
+ ## 기본 사용법
14
+
15
+ ### 서버 설정
16
+
17
+ ```typescript
18
+ // server.ts
19
+ import { Hono } from 'hono'
20
+ import { zValidator } from '@hono/zod-validator'
21
+ import { z } from 'zod'
22
+
23
+ const app = new Hono()
24
+ .get('/hello', (c) => {
25
+ return c.json({ message: 'Hello!' })
26
+ })
27
+ .get('/users/:id', (c) => {
28
+ const id = c.req.param('id')
29
+ return c.json({ id, name: 'John' })
30
+ })
31
+ .post(
32
+ '/users',
33
+ zValidator(
34
+ 'json',
35
+ z.object({
36
+ name: z.string(),
37
+ email: z.email(),
38
+ })
39
+ ),
40
+ (c) => {
41
+ const data = c.req.valid('json')
42
+ return c.json({ id: '1', ...data }, 201)
43
+ }
44
+ )
45
+
46
+ // ⭐ 타입 export 필수
47
+ export type AppType = typeof app
48
+ export default app
49
+ ```
50
+
51
+ ### 클라이언트 사용
52
+
53
+ ```typescript
54
+ // client.ts
55
+ import { hc } from 'hono/client'
56
+ import type { AppType } from './server'
57
+
58
+ // 클라이언트 생성
59
+ const client = hc<AppType>('http://localhost:8787/')
60
+
61
+ // GET 요청
62
+ async function getHello() {
63
+ const res = await client.hello.$get()
64
+ if (res.ok) {
65
+ const data = await res.json() // { message: string }
66
+ console.log(data.message)
67
+ }
68
+ }
69
+
70
+ // Path Parameter
71
+ async function getUser() {
72
+ const res = await client.users[':id'].$get({
73
+ param: { id: '123' },
74
+ })
75
+ const data = await res.json() // { id: string, name: string }
76
+ }
77
+
78
+ // POST 요청
79
+ async function createUser() {
80
+ const res = await client.users.$post({
81
+ json: {
82
+ name: 'John',
83
+ email: 'john@example.com',
84
+ },
85
+ })
86
+ if (res.status === 201) {
87
+ const data = await res.json()
88
+ console.log(data.id)
89
+ }
90
+ }
91
+ ```
92
+
93
+ ---
94
+
95
+ ## 요청 옵션
96
+
97
+ ### Query Parameters
98
+
99
+ ```typescript
100
+ // 서버
101
+ const app = new Hono().get(
102
+ '/search',
103
+ zValidator('query', z.object({ q: z.string(), page: z.coerce.number() })),
104
+ (c) => {
105
+ const { q, page } = c.req.valid('query')
106
+ return c.json({ query: q, page, results: [] })
107
+ }
108
+ )
109
+
110
+ // 클라이언트
111
+ const res = await client.search.$get({
112
+ query: { q: 'hono', page: '1' },
113
+ })
114
+ ```
115
+
116
+ ### Form Data
117
+
118
+ ```typescript
119
+ // 서버
120
+ const app = new Hono().post(
121
+ '/posts',
122
+ zValidator('form', z.object({ title: z.string(), body: z.string() })),
123
+ (c) => {
124
+ const data = c.req.valid('form')
125
+ return c.json({ post: data }, 201)
126
+ }
127
+ )
128
+
129
+ // 클라이언트
130
+ const res = await client.posts.$post({
131
+ form: {
132
+ title: 'Hello',
133
+ body: 'World',
134
+ },
135
+ })
136
+ ```
137
+
138
+ ### Headers
139
+
140
+ ```typescript
141
+ const res = await client.posts.$post(
142
+ {
143
+ json: { title: 'Test', body: 'Content' },
144
+ },
145
+ {
146
+ headers: {
147
+ 'X-Custom-Header': 'value',
148
+ },
149
+ }
150
+ )
151
+ ```
152
+
153
+ ---
154
+
155
+ ## 클라이언트 설정
156
+
157
+ ### 공통 헤더
158
+
159
+ ```typescript
160
+ const client = hc<AppType>('http://localhost:8787/', {
161
+ headers: {
162
+ Authorization: 'Bearer TOKEN',
163
+ },
164
+ })
165
+ ```
166
+
167
+ ### Credentials (쿠키 전송)
168
+
169
+ ```typescript
170
+ const client = hc<AppType>('http://localhost:8787/', {
171
+ init: {
172
+ credentials: 'include',
173
+ },
174
+ })
175
+ ```
176
+
177
+ ### 전체 설정
178
+
179
+ ```typescript
180
+ const client = hc<AppType>('http://localhost:8787/', {
181
+ headers: {
182
+ Authorization: 'Bearer TOKEN',
183
+ 'Content-Type': 'application/json',
184
+ },
185
+ init: {
186
+ credentials: 'include',
187
+ mode: 'cors',
188
+ },
189
+ })
190
+ ```
191
+
192
+ ---
193
+
194
+ ## 타입 추론
195
+
196
+ ### InferRequestType
197
+
198
+ ```typescript
199
+ import type { InferRequestType } from 'hono/client'
200
+
201
+ // POST 요청의 body 타입 추론
202
+ type CreateUserRequest = InferRequestType<typeof client.users.$post>['json']
203
+ // { name: string; email: string }
204
+
205
+ // Form 타입 추론
206
+ type PostFormRequest = InferRequestType<typeof client.posts.$post>['form']
207
+ ```
208
+
209
+ ### InferResponseType
210
+
211
+ ```typescript
212
+ import type { InferResponseType } from 'hono/client'
213
+
214
+ // 응답 타입 추론
215
+ type UserResponse = InferResponseType<typeof client.users[':id'].$get>
216
+ // { id: string; name: string }
217
+
218
+ // 특정 상태 코드의 응답 타입
219
+ type NotFoundResponse = InferResponseType<typeof client.users[':id'].$get, 404>
220
+ // { error: string }
221
+ ```
222
+
223
+ ---
224
+
225
+ ## 상태 코드 처리
226
+
227
+ ### 서버에서 명시적 상태 코드
228
+
229
+ ```typescript
230
+ // server.ts
231
+ const app = new Hono().get(
232
+ '/posts/:id',
233
+ zValidator('param', z.object({ id: z.string() })),
234
+ async (c) => {
235
+ const { id } = c.req.valid('param')
236
+ const post = await getPost(id)
237
+
238
+ if (!post) {
239
+ return c.json({ error: 'Post not found' }, 404) // 명시적 404
240
+ }
241
+
242
+ return c.json({ post }, 200) // 명시적 200
243
+ }
244
+ )
245
+
246
+ export type AppType = typeof app
247
+ ```
248
+
249
+ ### 클라이언트에서 상태 코드 처리
250
+
251
+ ```typescript
252
+ // client.ts
253
+ async function getPost(id: string) {
254
+ const res = await client.posts[':id'].$get({
255
+ param: { id },
256
+ })
257
+
258
+ if (res.status === 404) {
259
+ const data = await res.json() // { error: string }
260
+ console.log(data.error)
261
+ return null
262
+ }
263
+
264
+ if (res.status === 200) {
265
+ const data = await res.json() // { post: Post }
266
+ return data.post
267
+ }
268
+
269
+ throw new Error('Unexpected status')
270
+ }
271
+ ```
272
+
273
+ ---
274
+
275
+ ## URL 생성
276
+
277
+ ```typescript
278
+ // URL 객체 생성 (요청 없이)
279
+ const url = client.posts[':id'].$url({
280
+ param: { id: '123' },
281
+ })
282
+
283
+ console.log(url.pathname) // /posts/123
284
+ console.log(url.toString()) // http://localhost:8787/posts/123
285
+ ```
286
+
287
+ ---
288
+
289
+ ## 라우트 그룹화
290
+
291
+ ### 서버
292
+
293
+ ```typescript
294
+ // routes/users.ts
295
+ import { Hono } from 'hono'
296
+
297
+ const users = new Hono()
298
+ .get('/', (c) => c.json({ users: [] }))
299
+ .get('/:id', (c) => c.json({ id: c.req.param('id') }))
300
+ .post('/', (c) => c.json({ created: true }, 201))
301
+
302
+ export default users
303
+ export type UsersType = typeof users
304
+
305
+ // index.ts
306
+ import { Hono } from 'hono'
307
+ import users from './routes/users'
308
+
309
+ const app = new Hono().route('/users', users)
310
+
311
+ export type AppType = typeof app
312
+ export default app
313
+ ```
314
+
315
+ ### 클라이언트
316
+
317
+ ```typescript
318
+ import { hc } from 'hono/client'
319
+ import type { AppType } from './server'
320
+
321
+ const client = hc<AppType>('http://localhost:8787/')
322
+
323
+ // /users 엔드포인트 호출
324
+ await client.users.$get()
325
+ await client.users[':id'].$get({ param: { id: '123' } })
326
+ await client.users.$post({ json: { name: 'John' } })
327
+ ```
328
+
329
+ ---
330
+
331
+ ## 에러 처리
332
+
333
+ ```typescript
334
+ async function fetchUser(id: string) {
335
+ try {
336
+ const res = await client.users[':id'].$get({
337
+ param: { id },
338
+ })
339
+
340
+ if (!res.ok) {
341
+ const error = await res.json()
342
+ throw new Error(error.message || 'Request failed')
343
+ }
344
+
345
+ return await res.json()
346
+ } catch (err) {
347
+ if (err instanceof TypeError) {
348
+ // 네트워크 에러
349
+ console.error('Network error:', err)
350
+ }
351
+ throw err
352
+ }
353
+ }
354
+ ```
355
+
356
+ ---
357
+
358
+ ## 완전한 예제
359
+
360
+ ### 서버
361
+
362
+ ```typescript
363
+ // server.ts
364
+ import { Hono } from 'hono'
365
+ import { zValidator } from '@hono/zod-validator'
366
+ import { z } from 'zod'
367
+
368
+ const userSchema = z.object({
369
+ name: z.string().min(1),
370
+ email: z.email(),
371
+ })
372
+
373
+ const app = new Hono()
374
+ .get('/users', (c) => {
375
+ return c.json({ users: [{ id: '1', name: 'John' }] })
376
+ })
377
+ .get('/users/:id', (c) => {
378
+ const id = c.req.param('id')
379
+ return c.json({ user: { id, name: 'John' } })
380
+ })
381
+ .post('/users', zValidator('json', userSchema), (c) => {
382
+ const data = c.req.valid('json')
383
+ return c.json({ user: { id: '1', ...data } }, 201)
384
+ })
385
+ .put('/users/:id', zValidator('json', userSchema.partial()), (c) => {
386
+ const id = c.req.param('id')
387
+ const data = c.req.valid('json')
388
+ return c.json({ user: { id, ...data } })
389
+ })
390
+ .delete('/users/:id', (c) => {
391
+ return c.json({ success: true })
392
+ })
393
+
394
+ export type AppType = typeof app
395
+ export default app
396
+ ```
397
+
398
+ ### 클라이언트
399
+
400
+ ```typescript
401
+ // client.ts
402
+ import { hc } from 'hono/client'
403
+ import type { InferRequestType, InferResponseType } from 'hono/client'
404
+ import type { AppType } from './server'
405
+
406
+ const client = hc<AppType>('http://localhost:8787/', {
407
+ headers: {
408
+ Authorization: 'Bearer TOKEN',
409
+ },
410
+ })
411
+
412
+ // 타입 추론
413
+ type CreateUserInput = InferRequestType<typeof client.users.$post>['json']
414
+ type User = InferResponseType<typeof client.users[':id'].$get>['user']
415
+
416
+ // CRUD 함수
417
+ export const userApi = {
418
+ list: async () => {
419
+ const res = await client.users.$get()
420
+ return res.json()
421
+ },
422
+
423
+ get: async (id: string) => {
424
+ const res = await client.users[':id'].$get({ param: { id } })
425
+ return res.json()
426
+ },
427
+
428
+ create: async (data: CreateUserInput) => {
429
+ const res = await client.users.$post({ json: data })
430
+ return res.json()
431
+ },
432
+
433
+ update: async (id: string, data: Partial<CreateUserInput>) => {
434
+ const res = await client.users[':id'].$put({
435
+ param: { id },
436
+ json: data,
437
+ })
438
+ return res.json()
439
+ },
440
+
441
+ delete: async (id: string) => {
442
+ const res = await client.users[':id'].$delete({ param: { id } })
443
+ return res.json()
444
+ },
445
+ }
446
+ ```
447
+
448
+ ---
449
+
450
+ ## 관련 문서
451
+
452
+ - [기본 사용법](./index.md)
453
+ - [Zod 검증](./validation.md)
454
+ - [에러 처리](./error-handling.md)