nestjs offers the implementation of different microservice architectures. The framework allows Hybrid applications but also the setup of creating one microservice as one application. Is there a way
Is there an recommended way to use nest microservices in an nx environment since?
This is exactly what Id like to know! the nrwl nx docs are very lacking and unclear
Hi,
NX/NRWL offers a monorepo strategy while Microservices offer more isolated or independent architecture/structure as compared to other monolithic approaches.
I personally do not see a fruitful outcome of doing microservices with NX. It is not preventing us to do so, however if the agenda of microservice architecture is to have each feature independent of the other as a self-contained block, what is the purpose of tie them again with mono-repo.
The only concern of having one common node_modules should not kill the overall purpose of microservices.
-N Baua
Hi,
NX/NRWL offers a monorepo strategy while Microservices offer more isolated or independent architecture/structure as compared to other monolithic approaches.
I personally do not see a fruitful outcome of doing microservices with NX. It is not preventing us to do so, however if the agenda of microservice architecture is to have each feature independent of the other as a self-contained block, what is the purpose of tie them again with mono-repo.
The only concern of having one common node_modules should not kill the overall purpose of microservices.
-N Baua
Hey There,
There's a basic example of why you'd want your nestjs microservice inside a monorepo:
a microservice is fundamentally a message transmitter, and it can be used as part of bigger application to, mainly, allow a communication that uses a different transport layer than http, to your main app, in which you'd inject ClientProxy.
main app emits data, and the microservice intercepts it and does stuff. wouldnt you want them both to share the same DTOs?
Most of nestjs's concepts, such as dependency injection, decorators, exception filters, pipes, guards and interceptors, apply equally to microservices.
so it could become a lot more helpful then just having common node_modukes
@Tomshsh
Lovely feedback there. Agreed that with NX all the mentioned goodies will be available. however I see the microservices as a isolated box separated from one another in a way. If you ask, wouldn't you want them both to share the same DTOs? . Sure I would love to, however that makes my distributed microservice tied to something once again.
I'm not very much convinced with the idea of reusability of DTOs or other modules. The argument can be, there would be lots of duplication of code. Yes correct, however the point here is not to save on duplicating but to make each feature independent of each other.
Say for example, if I have a DTO which is commonly used across multiple microservices and if one of the column/field name changed(or worst removed), with one of the microservice project correctly implementing it post-change, yet another team unaware of such change working on separate microservice, would be in mess. Those impacted microservice(s) will immediately start to fail and so does the whole idea of using microservice as such.
I strongly believe for reusability of code/components/DTOs or any resources in general monolithic approach is working well and NRWL or NX is awesome for that, However for microservices world it might not be the best bait, in my opinion (PCIMW).
Please share your thoughts with context to continues build and deployment , if you're interested.
Thanks, loved your opinions.
@nbaua
Thanks for making this valid point, and of course for the lovely compliments.
I guess that even if I wanted to put a microservice in a monorepo, it wouldn't be much of a problem anyways :smile:
but thanks for clearing that out.
Most helpful comment
@nbaua
Thanks for making this valid point, and of course for the lovely compliments.
I guess that even if I wanted to put a microservice in a monorepo, it wouldn't be much of a problem anyways :smile:
but thanks for clearing that out.