#Can't Resolve Dependencies between two apps.

18 messages · Page 1 of 1 (latest)

high owl
#

I have two applications: Core and Chat. The Core application has common modules, including authentication. And chat, which have WebSocket implementations.

For security purposes, I want to use JwtAuthGuard on WebSocket handlers. To achieve this, I imported the AuthModule in ChatModule, as shown in the first screenshot. However, I'm receiving an error.

2024-02-05T22:22:39.288Z info:     Starting Nest application...
2024-02-05T22:22:39.312Z info:     PassportModule dependencies initialized
2024-02-05T22:22:39.314Z error:    Nest can't resolve dependencies of the UserEntityRepository (?). Please make sure that the argument DataSource at index [0] is available in the TypeOrmModule context.

Potential solutions:
- Is TypeOrmModule a valid NestJS module?
- If DataSource is a provider, is it part of the current TypeOrmModule?
- If DataSource is exported from a separate @Module, is that module imported within TypeOrmModule?
  @Module({
    imports: [ /* the Module containing DataSource */ ]
  })
covert spade
#

I suspect you're going to have to give us screenshots of the classes actually mentioned in the error

high owl
#

I am getting this error only when import the AuthModule in ChatModule.

#

And this is my UserModule.

covert spade
#

let's see userentityrepository

#

so far I would guess a missing injectable or injectrepository decorator?

toxic bronze
#

You said this was across multiple applications, yeah? How do you use the Core application in the Chat application?

high owl
#

So I don't use the whole CoreModule in the ChatModule because I just need only AuthModule. I guess it's not what I thought.

This is my structure btw:

toxic bronze
#

I guess the main question should be where is the TypeOrmModule.forRoot call?

high owl
#

in my database.module

toxic bronze
#

What imports the DatabaseModule?

high owl
#

my CoreModule imports

toxic bronze
#

And your ChatModule imports the CoreModule?

high owl
#

No it's not. Oh should I import the CoreModule instead of AuthModule ?

toxic bronze
#

Well, the DatabaseModule needs to be imported somehow

high owl
#

hmm. Oky I imported the CoreModule in ChatModule and error gone.

#

But now I can't use the jwtguard on the websocket :). But it's an another. issue. Thanks for helping.