Hi,
I am upgrading nestjs to latest in my project and I'm having some Nest can't resolve dependencies of the AuthGuard-related issues.
Basically I have an AuthModule like this
@Module({
imports: [
// ...
TypeOrmCustomRepositoryModule.forCustomRepository([
UserRepository,
]),
],
providers: [
// ...
AuthGuard,
],
exports: [
// ...
AuthGuard,
],
})
And in other modules, if I want to use my AuthGuard I'm importing AuthModule in imports array. Then I use AuthGuard in controllers.
This gives me error
Potential solutions:
- Is XYModule a valid NestJS module?
- If UserRepository is a provider, is it part of the current XYModule?
- If UserRepository is exported from a separate @Module, is that module imported within DynamicTagsModule?
@Module({
imports: [ /* the Module containing UserRepository */ ]
})```
I suspect that this is not what I'm supposed to do as using Authguard with `@UseGuards` does not seem to be injected like other providers/services.
Now I could go add UserRepository to imports of other modules but I don't think that is the right way.
So my question is what is the proper way to use AuthGuard? Import via modules or use directly as provider?