-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 (#581)
- Loading branch information
1 parent
f3d2d85
commit dd0e172
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
dd0e172
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
create-t3-app – ./
create-t3-app-t3-oss.vercel.app
create-t3-app-nu.vercel.app
beta.create.t3.gg
create-t3-app-git-next-t3-oss.vercel.app