Skip to content

Interface: CreateGuardsOptions<R> ​

Defined in: packages/trpc/src/guards.ts:81

The options of createGuards(): the shared handlers, plus a resolve that replaces ctx.rbac.

Extends ​

Type Parameters ​

Type ParameterDefault type
RSubjectRbac

Properties ​

PropertyTypeDescriptionInherited fromDefined in
exposeRequirements?booleanInclude the required roles/permissions in the default error (required in its body). Default: false (like spatie's display_permission_in_exception).GuardHandlers.exposeRequirementspackages/trpc/src/guards.ts:71
onForbidden?GuardHandler<R>Called when the subject lacks access. Default: a TRPCError FORBIDDEN.GuardHandlers.onForbiddenpackages/trpc/src/guards.ts:66
onUnauthenticated?GuardHandler<R>Called when there is no subject (ctx.rbac is null). Default: a TRPCError UNAUTHORIZED.GuardHandlers.onUnauthenticatedpackages/trpc/src/guards.ts:64
resolve?RbacResolver<R>Reads the subject of each call. Default: ctx.rbac, as createRbacContext() sets it. With resolve, the procedures don't need rbac in their context. It runs once per guard and call.-packages/trpc/src/guards.ts:86

Released under the MIT License. Inspired by spatie/laravel-permission.