Reputation: 505
in my team we use NestJS for our backend. We want to use microservices architecture and I've seen there is a built-in microservices support in NestJS. After read the documentation I've got a few questions about this feature:
createMicroservice
over NestFactory.create
? Using createMicroservice
also makes me to use @MessagePattern
and use an emitter to send messages - which is okay if my microservice gets messages using queue (like RabbitMQ), but I can't create REST API in my microservice, so it makes it harder (or impossible) to call NestJS microservice from non-NestJS microservice since it relies on NestJS MessagePattern
.Thanks ahead.
Upvotes: 1
Views: 2241
Reputation: 238
createMicroservice
is compulsory because nest needs to know what kind of controller you have and what behavior do you expect. In addition, you should avoid implementing rest API in all services; it should be implemented just in gateway service which is responsible for API layer, and it is a bond between microservices and outworld.For having a good notion about microservice implementation with NestJS I highly recommend you to take a look to this repo: https://github.com/Denrox/nestjs-microservices-example
Upvotes: 3