Kaizen
Browse modulesAccessaccess/serverFunctions

Function: makePermissionGuard()

function makePermissionGuard(access: AccessService): (subject: Subject, action: `${string}.${string}`, options?: RequirePermissionOptions) => Promise<Decision>;

Defined in: server/access/guard.ts:60

Curry a reusable guard bound to an AccessService. Mirrors the accessProcedure(action) ergonomics the design calls for — a consumer can build their tRPC/RSC middleware on top of the returned function.

Parameters

ParameterType
accessAccessService

Returns

(subject: Subject, action: `${string}.${string}`, options?: RequirePermissionOptions) => Promise<Decision>

Example

const guard = makePermissionGuard(access);
await guard(subject, "product.publish", { resource });

On this page