【发布时间】:2019-11-03 07:10:02
【问题描述】:
我想知道在引导我的微服务期间我是否以正确的方式获取 ConfigService。
有没有办法使用 NestFactory.createMicroservice() 来做到这一点?
async function bootstrap() {
const app = await NestFactory.create(CoreModule, {
logger: new MyLogger(),
});
const configService: ConfigService = app.get(ConfigService);
app.connectMicroservice({
transport: Transport.TCP,
options: {
port: configService.PORT,
},
});
await app.startAllMicroservicesAsync();
}
【问题讨论】:
-
有一个关于这个话题的 Github issue:github.com/nestjs/nest/issues/2343
标签: node.js microservices nestjs