forked from t3-oss/create-t3-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: align trpc usage to official docs (t3-oss#581)
- Loading branch information
1 parent
ba012c0
commit 0e33131
Showing
12 changed files
with
62 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"create-t3-app": minor | ||
--- | ||
|
||
export helper procedures for trpc instead of the `t`-object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { t, authedProcedure } from "../trpc"; | ||
import { router, publicProcedure, protectedProcedure } from "../trpc"; | ||
|
||
export const authRouter = t.router({ | ||
getSession: t.procedure.query(({ ctx }) => { | ||
export const authRouter = router({ | ||
getSession: publicProcedure.query(({ ctx }) => { | ||
return ctx.session; | ||
}), | ||
getSecretMessage: authedProcedure.query(() => { | ||
getSecretMessage: protectedProcedure.query(() => { | ||
return "You are logged in and can see this secret message!"; | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import { t } from "../trpc"; | ||
import { router, publicProcedure } from "../trpc"; | ||
import { z } from "zod"; | ||
|
||
export const exampleRouter = t.router({ | ||
hello: t.procedure | ||
export const exampleRouter = router({ | ||
hello: publicProcedure | ||
.input(z.object({ text: z.string().nullish() }).nullish()) | ||
.query(({ input }) => { | ||
return { | ||
greeting: `Hello ${input?.text ?? "world"}`, | ||
}; | ||
}), | ||
getAll: t.procedure.query(({ ctx }) => { | ||
getAll: publicProcedure.query(({ ctx }) => { | ||
return ctx.prisma.example.findMany(); | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters