Bird
0
0

Which of the following is the correct method signature for a guard's access check in NestJS?

easy📝 Syntax Q3 of 15
NestJS - Guards
Which of the following is the correct method signature for a guard's access check in NestJS?
AhandleRequest(req: Request): boolean
BcheckAccess(context: Context): void
CcanActivate(context: ExecutionContext): boolean | Promise<boolean>
DvalidateUser(user: User): boolean
Step-by-Step Solution
Solution:
  1. Step 1: Recall the guard interface method

    The guard interface requires a canActivate method with ExecutionContext parameter returning boolean or Promise.
  2. Step 2: Eliminate incorrect signatures

    Other methods and parameters do not match the NestJS guard pattern.
  3. Final Answer:

    canActivate(context: ExecutionContext): boolean | Promise -> Option C
  4. Quick Check:

    Guard method signature = B [OK]
Quick Trick: Guard method is canActivate with ExecutionContext [OK]
Common Mistakes:
  • Using wrong method names
  • Missing ExecutionContext parameter
  • Returning void instead of boolean

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes