diff --git a/.changeset/loud-maps-stare.md b/.changeset/loud-maps-stare.md new file mode 100644 index 0000000..f31fc5d --- /dev/null +++ b/.changeset/loud-maps-stare.md @@ -0,0 +1,5 @@ +--- +"create-better-t-stack": patch +--- + +Improve type safety for orpc protectedProcedure context diff --git a/apps/cli/templates/api/orpc/server/base/src/lib/orpc.ts.hbs b/apps/cli/templates/api/orpc/server/base/src/lib/orpc.ts.hbs index 8bbd3a9..21e0c9b 100644 --- a/apps/cli/templates/api/orpc/server/base/src/lib/orpc.ts.hbs +++ b/apps/cli/templates/api/orpc/server/base/src/lib/orpc.ts.hbs @@ -10,7 +10,12 @@ const requireAuth = o.middleware(async ({ context, next }) => { if (!context.session?.user) { throw new ORPCError("UNAUTHORIZED"); } - return next({ context }); + return next({ + context: { + ...context, + session: context.session, + }, + }); }); export const protectedProcedure = publicProcedure.use(requireAuth);