Complete the code to import the decorator used to define roles in NestJS.
import { [1] } from '@nestjs/common';
The SetMetadata decorator is used to define custom metadata like roles in NestJS.
Complete the code to create a custom decorator named Roles that sets roles metadata.
export const Roles = (...roles: string[]) => [1]('roles', roles);
The SetMetadata function attaches the roles array as metadata to the route handler.
Fix the error in the guard to get roles metadata using the correct method.
const roles = this.reflector.[1]('roles', context.getHandler());
The Reflector class uses the get method to retrieve metadata by key.
Fill both blanks to check if the user has any of the required roles in the guard.
return roles.some(role => user.roles.[1](role)) && user.isActive === [2];
The includes method checks if the user's roles contain the required role. The user must be active, so true is checked.
Fill both blanks to apply the Roles decorator and guard to a controller route.
@[1]('admin') @UseGuards([2]) @Get('admin') adminRoute() { return 'Admin content'; }
The Roles decorator sets roles metadata, RolesGuard enforces role checks.