mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
Update orpc.ts.hbs (#235)
Co-authored-by: Aman Varshney <amanvarshney.work@gmail.com>
This commit is contained in:
5
.changeset/loud-maps-stare.md
Normal file
5
.changeset/loud-maps-stare.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"create-better-t-stack": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Improve type safety for orpc protectedProcedure context
|
||||||
@@ -10,7 +10,12 @@ const requireAuth = o.middleware(async ({ context, next }) => {
|
|||||||
if (!context.session?.user) {
|
if (!context.session?.user) {
|
||||||
throw new ORPCError("UNAUTHORIZED");
|
throw new ORPCError("UNAUTHORIZED");
|
||||||
}
|
}
|
||||||
return next({ context });
|
return next({
|
||||||
|
context: {
|
||||||
|
...context,
|
||||||
|
session: context.session,
|
||||||
|
},
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
export const protectedProcedure = publicProcedure.use(requireAuth);
|
export const protectedProcedure = publicProcedure.use(requireAuth);
|
||||||
|
|||||||
Reference in New Issue
Block a user