Reputation: 1164
How can i create a microservice that contains all the shared/common login/classes between projects?
I have a gateway, and different microservices, let say auth and account.
How can I share the user.model
for example, considering that both services will use that entity?
Also considering that some common methods can be located in this common microservices in order to not have the code duplicated.
Upvotes: 1
Views: 4149
Reputation: 412
Check out the library module of microservice in Nestjs
https://docs.nestjs.com/cli/libraries
Here you can create a library module with the command
nest g library my-library
Then in that module, you can put the shared module like constant, util, etc which are common in all microservices.
To use that module import like this
import { MyLibraryModule } from '@app/my-library';
Upvotes: 3