ea28d9f5 months ago29 lines · 728 B| 1 | import { ORPCError, os } from "@orpc/server"; |
| 2 | |
| 3 | import type { Context |
| 4 | |
| 5 | export const o = |
| 6 | |
| 7 | export const publicProcedure = |
| 8 | |
| 9 | const requireAuth = o |
| 10 | if (!context.session |
| 11 | throw new ORPCError( |
| 12 | } |
| 13 | return next({ |
| 14 | context: { |
| 15 | session: context.session |
| 16 | }, |
| 17 | }); |
| 18 | }); |
| 19 | |
| 20 | export const protectedProcedure = |
| 21 | |
| 22 | const requireAdmin = o |
| 23 | if (!context.session |
| 24 | throw new ORPCError( |
| 25 | } |
| 26 | return next(); |
| 27 | }); |
| 28 | |
| 29 | export const adminProcedure = |