15
server/trpc/router.ts
Normal file
15
server/trpc/router.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { Context } from './context'
|
||||
import { initTRPC } from '@trpc/server'
|
||||
|
||||
const t = initTRPC.context<Context>().create()
|
||||
|
||||
export const router = t.router
|
||||
|
||||
export const publicProcedure = t.procedure
|
||||
|
||||
export const protectedProcedure = t.procedure.use(({ ctx, next }) => {
|
||||
if (!ctx.session?.fresh)
|
||||
throw new Error('UNAUTHORIZED')
|
||||
|
||||
return next({ ctx: { ...ctx } })
|
||||
})
|
||||
Reference in New Issue
Block a user