Skip to content

Commit f25fc43

Browse files
authored
Merge pull request #3 from revgum/patch-1
Updates documentation to reflect the implementation
2 parents 436961c + 9fa6a80 commit f25fc43

1 file changed

Lines changed: 56 additions & 39 deletions

File tree

README.md

Lines changed: 56 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,11 @@ export const appRouter = t.router({
161161
getUser: t.procedure
162162
.meta({
163163
name: 'Get User',
164-
description: 'Retrieve user information by ID',
165-
tags: ['Users'],
166-
auth: true
164+
docs: {
165+
description: 'Retrieve user information by ID',
166+
tags: ['Users'],
167+
auth: true
168+
}
167169
})
168170
.input(z.object({ userId: z.string() }))
169171
.output(
@@ -181,10 +183,12 @@ export const appRouter = t.router({
181183
createPost: t.procedure
182184
.meta({
183185
name: 'Create Post',
184-
description: 'Create a new blog post',
185-
tags: ['Posts'],
186-
auth: true,
187-
roles: ['admin', 'editor']
186+
docs: {
187+
description: 'Create a new blog post',
188+
tags: ['Posts'],
189+
auth: true,
190+
roles: ['admin', 'editor']
191+
}
188192
})
189193
.input(
190194
z.object({
@@ -402,16 +406,19 @@ Type definition for route metadata (use with `initTRPC.meta<RouteMeta>()`):
402406
type RouteMeta = {
403407
/** Human-readable name for the route */
404408
name?: string;
405-
/** Description of what the route does */
406-
description?: string;
407-
/** Tags for grouping routes */
408-
tags?: string[];
409-
/** Whether this route is deprecated */
410-
deprecated?: boolean;
411-
/** Whether this route requires authentication */
412-
auth?: boolean;
413-
/** Roles allowed to access this route */
414-
roles?: string[];
409+
/** Documentation metadata */
410+
docs?: {
411+
/** Description of what the route does */
412+
description?: string;
413+
/** Tags for grouping routes */
414+
tags?: string[];
415+
/** Whether this route is deprecated */
416+
deprecated?: boolean;
417+
/** Whether this route requires authentication */
418+
auth?: boolean;
419+
/** Roles allowed to access this route */
420+
roles?: string[];
421+
}
415422
};
416423
```
417424

@@ -433,8 +440,10 @@ export const appRouter = t.router({
433440
health: t.procedure
434441
.meta({
435442
name: 'Health Check',
436-
description: 'Check if the API is running',
437-
tags: ['System']
443+
docs: {
444+
description: 'Check if the API is running',
445+
tags: ['System']
446+
}
438447
})
439448
.output(z.object({ status: z.literal('ok') }))
440449
.query(() => ({ status: 'ok' as const })),
@@ -444,10 +453,12 @@ export const appRouter = t.router({
444453
list: t.procedure
445454
.meta({
446455
name: 'List Users',
447-
description: 'Get a paginated list of users',
448-
tags: ['Users'],
449-
auth: true,
450-
roles: ['admin']
456+
docs: {
457+
description: 'Get a paginated list of users',
458+
tags: ['Users'],
459+
auth: true,
460+
roles: ['admin']
461+
}
451462
})
452463
.input(
453464
z.object({
@@ -478,10 +489,12 @@ export const appRouter = t.router({
478489
getByEmail: t.procedure
479490
.meta({
480491
name: 'Get User by Email',
481-
description: 'Retrieve user by email address',
482-
tags: ['Users'],
483-
deprecated: true,
484-
auth: true
492+
docs: {
493+
description: 'Retrieve user by email address',
494+
tags: ['Users'],
495+
deprecated: true,
496+
auth: true
497+
}
485498
})
486499
.input(z.object({ email: z.string().email() }))
487500
.output(
@@ -560,19 +573,23 @@ t.procedure.input(
560573
```typescript
561574
t.procedure.meta({
562575
name: 'Create User', // Clear, readable name
563-
description: 'Creates a new user account with the provided information',
564-
tags: ['Users', 'Authentication'], // Logical grouping
565-
auth: true, // Show auth requirement
566-
roles: ['admin'] // Show role requirements
576+
docs: {
577+
description: 'Creates a new user account with the provided information',
578+
tags: ['Users', 'Authentication'], // Logical grouping
579+
auth: true, // Show auth requirement
580+
roles: ['admin'] // Show role requirements
581+
}
567582
});
568583
```
569584

570585
### 2. Mark Deprecated Routes
571586

572587
```typescript
573588
t.procedure.meta({
574-
deprecated: true,
575-
description: 'Use users.getById instead'
589+
docs: {
590+
deprecated: true,
591+
description: 'Use users.getById instead'
592+
}
576593
});
577594
```
578595

@@ -581,14 +598,14 @@ t.procedure.meta({
581598
```typescript
582599
const appRouter = t.router({
583600
// All auth-related routes
584-
login: t.procedure.meta({ tags: ['Authentication'] }),
585-
logout: t.procedure.meta({ tags: ['Authentication'] }),
586-
register: t.procedure.meta({ tags: ['Authentication'] }),
601+
login: t.procedure.meta({ docs: { tags: ['Authentication'] } }),
602+
logout: t.procedure.meta({ docs: { tags: ['Authentication'] } }),
603+
register: t.procedure.meta({ docs: { tags: ['Authentication'] } }),
587604

588605
// All user-related routes
589-
getUser: t.procedure.meta({ tags: ['Users'] }),
590-
updateUser: t.procedure.meta({ tags: ['Users'] }),
591-
deleteUser: t.procedure.meta({ tags: ['Users'] })
606+
getUser: t.procedure.meta({ docs: { tags: ['Users'] } }),
607+
updateUser: t.procedure.meta({ docs: { tags: ['Users'] } }),
608+
deleteUser: t.procedure.meta({ docs: { tags: ['Users'] } })
592609
});
593610
```
594611

0 commit comments

Comments
 (0)