Skip to content

Type Alias: RbacRequest<T, Req, G> ​

ts
type RbacRequest<T, Req, G> = Omit<Req, "rbac"> & object;

Defined in: packages/express/src/middleware.ts:48

An Express request whose rbac has the names of T (a names type like AppRbac, or typeof rbac). With per-guard names, G is the guard of the request (the default guard's names by default): RbacRequest<typeof rbac, Request, 'api'> on the routes of an api middleware. For typing a handler without a global RbacRegister, e.g. when two routers use different engines:

ts
app.get('/articles', (req: RbacRequest<typeof rbac>, res) => { ... })

Type Parameters ​

Type ParameterDefault type
T extends RbacTypeConfig | Rbac<RbacTypeConfig>DefaultRbacTypes
ReqRequest
G extends stringDefaultGuardName<TypesOf<T>>

Type Declaration ​

NameTypeDescriptionDefined in
rbac?| SubjectRbac<TypesOf<T>, ScopedGuardName<TypesOf<T>, G>> | nullRoles & permissions of the current subject, set by rbacMiddleware(). null for guests, undefined when the middleware did not run.packages/express/src/middleware.ts:57

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