function Roles
Since 0.1.0
Roles(...roles: string[]): SetuClassOrMethodDecorator

Requires the authenticated principal to hold any of the given roles. May be applied at the class level (default for all routes) or method level (overrides the class default).

Enforced by DecoratorPlugin unless enforceRoles: false: the route's chain gets middleware that answers 401 without a principal, 403 when the principal holds none of the roles, and — when no authorization provider is registered at all — 501 (fail closed, with a startup warning naming both remedies).

Parameters

...roles: string[]

One or more role names

Return Type

A class or method decorator

Usage

import { Roles } from "decorator-plugin/src/index.ts";