可以在nest中连接这两种方法——微服务和普通应用。文档中没有提到这一点,但FAQ解释了如何制作
Hybrid application
.
这个
GRPC example
在行动中表现出来
import { NestFactory } from '@nestjs/core';
import { MicroserviceOptions } from '@nestjs/microservices';
import { AppModule } from './app.module';
import { grpcClientOptions } from './grpc-client.options';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.connectMicroservice<MicroserviceOptions>(grpcClientOptions);
await app.startAllMicroservicesAsync();
await app.listen(3001);
console.log(`Application is running on: ${await app.getUrl()}`);
}
bootstrap();
通过这种方式,可以连接带有kafka/rabbit/grpc的rest api