Skip to content

ActionServices

ActionServices = Record<string, any>

Defined in: packages/actions/src/types.ts:37

A record of arbitrary external services an action handler may depend on.

Services are registered once at createActions time and made available on every action’s ActionContext via ctx.services. Use this to inject HTTP clients, email providers, cache adapters, third-party APIs, etc., without each handler having to import them directly — which both improves testability (services can be mocked per-suite) and keeps action modules decoupled from concrete providers.

type Services = {
nutritionApi: { lookup: (name: string) => Promise<Nutrition> };
mailer: { sendWelcome: (to: string) => Promise<void> };
};