oRPC Context
Installation
SKILL.md
Context in oRPC
oRPC's context mechanism provides a type-safe dependency injection pattern. Two types:
- Initial Context: Provided explicitly when invoking a procedure.
- Execution Context: Generated during procedure execution, typically by middleware.
Initial Context
const base = os.$context<{ headers: Headers, env: { DB_URL: string } }>()
const getting = base.handler(async ({ context }) => {
console.log(context.env)
})
export const router = { getting }