Closed Saro-DA closed 3 years ago
In this example I used https://github.com/AlariCode/nestjs-dotenv.
import { ConfigModule, ConfigService } from 'nestjs-dotenv';
const configService = new ConfigService();
@Module({
imports: [
ConfigModule.forRoot(),
RMQModule.forRoot({
exchangeName: configService.get('AMQP_EXCHANGE'),
connections: [
{
login: configService.get('AMQP_LOGIN'),
password: configService.get('AMQP_PASSWORD'),
host: configService.get('AMQP_HOST'),
},
],
}),
],
})
export class AppModule {}
Imo module should expose forRootAsync
method and then you can inject standard injectable service e.g nest/config
ConfigService
const configService = new ConfigService();
is not an elegant solution
@m-czyz, thanks, I’ll look into adding forRootAsync. Pull request will be appreciated.
Added forRootAsync support in 1.11.0 version
Hi.
In your example:
Can you please explain how can we access the configService in this module? In the example that you provided you have hardcoded the settings.
Thanks.