Skip to content

Commit 37116a2

Browse files
authored
Merge pull request #42 from grmkris/patch-1
Update trpc.md
2 parents a42198d + 02602d1 commit 37116a2

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

docs/plugins/trpc.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,26 @@ bun add @elysiajs/trpc @trpc/server @elysiajs/websocket
2424

2525
Then use it:
2626
```typescript
27-
import { Elysia, t as T } from 'elysia'
28-
import { trpc, compile as c } from '@elysiajs/trpc'
29-
import { z } from 'zod'
27+
import { compile as c, trpc } from "@elysiajs/trpc";
28+
import { initTRPC } from "@trpc/server";
29+
import { Elysia, t as T } from "elysia";
3030

31-
import { initTRPC } from '@trpc/server'
32-
33-
const t = initTRPC.create()
34-
const p = t.prodcedure
31+
const t = initTRPC.create();
32+
const p = t.procedure;
3533

3634
const router = t.router({
37-
greet: p
38-
// or using Zod
39-
.input(z.string())
40-
// Using Elysia's T
41-
.input(c(t.String()))
42-
.query(({ input }) => input)
43-
})
35+
greet: p
36+
37+
// 💡 Using Zod
38+
//.input(z.string())
39+
// 💡 Using Elysia's T
40+
.input(c(T.String()))
41+
.query(({ input }) => input),
42+
});
4443

45-
export type Router = typeof router
44+
export type Router = typeof router;
4645

47-
const app = new Elysia()
48-
.use(trpc(router))
49-
.listen(8080)
46+
const app = new Elysia().use(trpc(router)).listen(8080);
5047
```
5148

5249
## trpc

0 commit comments

Comments
 (0)