NestJS - GuardsWhich decorator is commonly used to specify roles required by a role-based guard in NestJS?A@Roles()B@Injectable()C@Controller()D@Get()Check Answer
Step-by-Step SolutionSolution:Step 1: Recall decorators related to rolesThe @Roles() decorator is used to define roles allowed for a route.Step 2: Differentiate from other decorators@Injectable() marks services, @Controller() marks controllers, @Get() marks HTTP GET routes.Final Answer:@Roles() -> Option AQuick Check:Role decorator = @Roles() [OK]Quick Trick: Use @Roles() to specify allowed roles on routes [OK]Common Mistakes:Using @Injectable() to specify rolesConfusing route decorators with role decoratorsOmitting role decorators entirely
Master "Guards" in NestJS9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallPerf
More NestJS Quizzes Authentication - Local strategy (username/password) - Quiz 8hard Database with Prisma - CRUD with Prisma - Quiz 12easy Database with Prisma - Why Prisma offers type-safe database access - Quiz 1easy Interceptors - Interceptor interface - Quiz 9hard Middleware - Why middleware processes requests before handlers - Quiz 14medium Middleware - Global middleware - Quiz 15hard Pipes - Custom pipes - Quiz 14medium Pipes - Why pipes transform and validate input - Quiz 10hard Pipes - Pipe binding (parameter, method, controller, global) - Quiz 4medium Pipes - File validation pipe - Quiz 5medium