Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a Config module/service #58

Closed
ziazon opened this issue Oct 30, 2019 · 3 comments
Closed

Using a Config module/service #58

ziazon opened this issue Oct 30, 2019 · 3 comments

Comments

@ziazon
Copy link

ziazon commented Oct 30, 2019

So I tried

    RabbitMQModule.forRootAsync({
      useFactory: (config: ConfigService) => ({
        exchanges: [
          {
            name: config.rmqExchange,
            type: 'topic'
          }
        ],
        uri: config.rmqUrl
      })
    })

and at first I got the following error, which was odd because I'm pretty sure this is a bug?
image

So then i installed @nestjs-plus/common and then i got what looks like an implementation error on my part:

image

I'm basically trying to pass in a config from another module (my ConfigModule which exposes a ConfigService) Any thoughts?

@WonderPanda
Copy link
Collaborator

WonderPanda commented Oct 30, 2019

@jubairsaidi Interesting regarding the missing @nestjs-plus/common. It should be installed as dependency of @nestjs-plus/rabbitmq. The TS error you're getting is saying that uri is expecting a single string, but what you're getting back from config.rmqUrl is a string[]. Are you intending to try and pass multiple URIs?

@WonderPanda
Copy link
Collaborator

@jubairsaidi You can see examples of different configuration techniques in the test suite that should cover what you're trying to do (once you fix the Type error):
https://github.com/WonderPanda/nestjs-plus/blob/master/integration/rabbitmq/e2e/configuration.e2e-spec.ts

@ziazon
Copy link
Author

ziazon commented Oct 31, 2019

Thanks! that's very helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants