Bird
0
0

Which of the following is the correct way to extend the PassportStrategy for a local strategy in NestJS?

easy📝 Syntax Q3 of 15
NestJS - Authentication
Which of the following is the correct way to extend the PassportStrategy for a local strategy in NestJS?
Aclass LocalStrategy extends Passport {}
Bclass LocalStrategy extends PassportStrategy {}
Cclass LocalStrategy extends PassportStrategy(Strategy) {}
Dclass LocalStrategy extends Strategy {}
Step-by-Step Solution
Solution:
  1. Step 1: Recall the correct inheritance syntax

    In NestJS, to create a local strategy, you extend PassportStrategy passing the Strategy from passport-local.
  2. Step 2: Check each option

    Only class LocalStrategy extends PassportStrategy(Strategy) {} correctly extends PassportStrategy(Strategy). Others miss the parameter or use wrong base classes.
  3. Final Answer:

    class LocalStrategy extends PassportStrategy(Strategy) {} -> Option C
  4. Quick Check:

    Extend PassportStrategy with Strategy param [OK]
Quick Trick: Extend PassportStrategy(Strategy) for local auth [OK]
Common Mistakes:
  • Forgetting to pass Strategy to PassportStrategy
  • Extending PassportStrategy without parameters
  • Extending wrong base classes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NestJS Quizzes