implementEffect(contract, layerOrRuntime) creates an Effect-aware contract implementer.
import.ts
Signature
signature.ts
Implement a contract
router.ts
Add context and middleware
context.ts
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Create an Effect-aware implementer for an oRPC contract.
implementEffect(contract, layerOrRuntime) creates an Effect-aware contract implementer.
import { implementEffect } from "effect-orpc";
const oe = implementEffect(contract, AppLive);
// or
const oe = implementEffect(contract, runtime);
const oe = implementEffect(contract, UsersRepoLive);
export const router = oe.router({
users: {
get: oe.users.get.effect(function* ({ input }) {
const usersRepo = yield* UsersRepo;
return yield* usersRepo.findById(input.id);
}),
},
});
const oe = implementEffect(contract, runtime)
.$context<RequestContext>()
.use(({ context, next }) =>
next({ context: { requestLabel: `${context.role}:${context.requestId}` } }),
);
| Method | Purpose |
|---|---|
.use(...) | Add middleware to this contract leaf. |
.handler(...) | Implement with a standard oRPC handler. |
.effect(...) | Implement with an Effect handler. |
Was this page helpful?