S
S
Speakermen2021-09-24 10:14:36
Angular
Speakermen, 2021-09-24 10:14:36

What do you need to know to understand nest.js or angular?

Some kind of decorators, dto, modules, services, etc.(

This code is confusing when reading the book Nest.js- A Progressive Node.js Framework( You need a level like the author of Greg Magolan is a Senior Architect, Full-Stack Engineer, if yes then how to achieve?
and Angular

@Injectable()
export default class JwtStrategy extends PassportStrategy(Strategy) {
  constructor(private readonly authenticationService: AuthenticationService) {
    super({
      jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
      passReqToCallback: true,
      secretOrKey: 'secret',
    });
  }
  public async validate(req, payload, done) {
    const isValid = await this.authenticationService.validateUser(payload);
    if (!isValid) {
      return done('Unauthorized', null);
    } else {
      return done(null, payload);
    }
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2021-09-24
@Speakermen

If you do not understand the meaning of the terms decorator, dto, module, service, etc., then I advise you to first familiarize yourself with design patterns, for example, here: https://refactoring.guru/en/design-patterns/
You can find a separate book on patterns and read her, you can take a course, watch a video on YouTube - whatever your heart desires.
After that, I would gradually begin to study the documentation of the framework you are interested in and, in parallel, google why this or that entity is needed, if it is not clear. So that learning the framework is not messy and chaotic, you can again take any course that will guide you through the basics by the hand, and then it’s up to your curiosity.
If we talk about the code snippet from your example, then to understand what is happening here, you can read about JWT (Json Web Token) and the Passport.js library and in general what are the methods of authorization / authentication and how they work

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question