Update orpc.ts.hbs (#235)

Co-authored-by: Aman Varshney <amanvarshney.work@gmail.com>
This commit is contained in:
Wiwat Srisattha
2025-05-08 19:01:02 +07:00
committed by GitHub
parent 31b6cc7109
commit 296ea3d59e
2 changed files with 11 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
"create-better-t-stack": patch
---
Improve type safety for orpc protectedProcedure context

View File

@@ -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);