Skip to content

ActionContext

ActionContext<TUser, TServices> = object

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

Context provided to every action’s OperationsFn.

Created by the getContext callback in ActionsConfig and passed alongside the database instance and parsed input to each action. When services are registered with createActions, they appear on ctx.services so handlers can access them without importing module- level singletons.

const ctx: ActionContext<{ id: string; role: string }, { nutritionApi: NutritionApi }> = {
db,
user: { id: "u_1", role: "author" },
grants: [{ action: "manage", subject: "all" }],
services: { nutritionApi },
};

TUser

The shape of the authenticated user object.

TServices extends ActionServices = ActionServices

The shape of the registered services map. Defaults to an empty record when no services are registered.

db: Db

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

The Drizzle database instance from @cfast/db.


grants: Grant[]

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

The user’s permission grants, used for permission checking.


services: TServices

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

External services registered with createActions. Defaults to an empty object {} when no services are provided at factory time, so handlers can always safely destructure ctx.services.


user: TUser

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

The authenticated user for the current request.