Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Provide a CurrentUser service from request context.
import { Context, Effect } from "effect"; import { eos } from "effect-orpc"; class CurrentUser extends Context.Tag("CurrentUser")< CurrentUser, { id: string; role: "admin" | "member" } >() {} const authedProcedure = eos .$context<{ user: { id: string; role: "admin" | "member" } }>() .provide(CurrentUser, ({ context }) => Effect.succeed(context.user)); export const router = { me: authedProcedure.effect(function* () { return yield* CurrentUser; }), };
const adminProcedure = authedProcedure.use(function* () { const user = yield* CurrentUser; if (user.role !== "admin") { return yield* Effect.fail(new ForbiddenError()); } });
Was this page helpful?