const t = initTRPC.context<Context>().create();
const isAuthed = t.middleware(async ({ next, ctx }) => {
if (!ctx) {
throw new TRPCError({
code: "UNAUTHORIZED",
});
}
return next({
ctx: {
session: ctx,
},
});
});
export const protectedProcedure = t.procedure.use(isAuthed);
const t = initTRPC.context<Context>().create();
const isAuthed = t.middleware(async ({ next, ctx }) => {
if (!ctx) {
throw new TRPCError({
code: "UNAUTHORIZED",
});
}
return next({
ctx: {
session: ctx,
},
});
});
export const protectedProcedure = t.procedure.use(isAuthed);