Route guard that authorizes action on subject against the request's ability.
Reads the ability attached by AbilityMiddleware; if it is missing or denies the action, it
throws an AuthorizationError (403). Attach it to a route's middleware
(@Delete('/posts/:id', { middleware: [authorize('delete', 'Post')] })). The same CASL rules
power the frontend, so the UI and the API stay in lockstep.
Route guard that authorizes
actiononsubjectagainst the request's ability.Reads the ability attached by
AbilityMiddleware; if it is missing or denies the action, it throws anAuthorizationError(403). Attach it to a route'smiddleware(@Delete('/posts/:id', { middleware: [authorize('delete', 'Post')] })). The same CASL rules power the frontend, so the UI and the API stay in lockstep.