我想知道在引导我的微服务期间是否以正确的方式获取 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();
}
Run Code Online (Sandbox Code Playgroud)