From cbf719d5573d0d273b1b0ab7fbae7b59bd75bd32 Mon Sep 17 00:00:00 2001 From: Aleksei Gurianov Date: Mon, 19 Aug 2024 20:15:39 +0300 Subject: [PATCH] Align all templates to use publicProcedure for `getLatest` method Fixes #1961 Fix the issue with errors on a fresh T3 app install by changing `getLatest` to use `publicProcedure` instead of `protectedProcedure`. * **cli/template/extras/src/server/api/routers/post/with-auth.ts** - Change `getLatest` to use `publicProcedure` instead of `protectedProcedure`. * **cli/template/extras/src/server/api/routers/post/with-auth-prisma.ts** - Change `getLatest` to use `publicProcedure` instead of `protectedProcedure`. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/t3-oss/create-t3-app/issues/1961?shareId=XXXX-XXXX-XXXX-XXXX). --- .../extras/src/server/api/routers/post/with-auth-prisma.ts | 2 +- cli/template/extras/src/server/api/routers/post/with-auth.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/template/extras/src/server/api/routers/post/with-auth-prisma.ts b/cli/template/extras/src/server/api/routers/post/with-auth-prisma.ts index b602dd5776..8760fdfd82 100644 --- a/cli/template/extras/src/server/api/routers/post/with-auth-prisma.ts +++ b/cli/template/extras/src/server/api/routers/post/with-auth-prisma.ts @@ -26,7 +26,7 @@ export const postRouter = createTRPCRouter({ }); }), - getLatest: protectedProcedure.query(async ({ ctx }) => { + getLatest: publicProcedure.query(async ({ ctx }) => { const post = await ctx.db.post.findFirst({ orderBy: { createdAt: "desc" }, where: { createdBy: { id: ctx.session.user.id } }, diff --git a/cli/template/extras/src/server/api/routers/post/with-auth.ts b/cli/template/extras/src/server/api/routers/post/with-auth.ts index 199b617fe6..632ccfb7b3 100644 --- a/cli/template/extras/src/server/api/routers/post/with-auth.ts +++ b/cli/template/extras/src/server/api/routers/post/with-auth.ts @@ -27,7 +27,7 @@ export const postRouter = createTRPCRouter({ return post; }), - getLatest: protectedProcedure.query(() => { + getLatest: publicProcedure.query(() => { return post; }),