Skip to content

Type Alias: Guard<N, O, R, C> ​

ts
type Guard<N, O, R, C> = <A>(...args) => RbacMiddleware<R, C>;

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

A guard typed with the names N it accepts and its options O: (...names, options?). Every name (each part of a 'a|b' list, each array item) must be one of N; with N = string, any name is. A call without names, or with options that are not the last argument, is a type error. The middleware narrows ctx.rbac to R, and needs the context C.

Type Parameters ​

Type ParameterDefault type
N extends string-
O-
RSubjectRbac
CRbacProcedureContext

Type Parameters ​

Type Parameter
A extends readonly (GuardNames | O)[]

Parameters ​

ParameterType
...argsA & RequirementArgs<A, N, O>

Returns ​

RbacMiddleware<R, C>

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