ms-nestjs-eureka
v1.0.2
Published
A NestJS module that integrate eureka-js-client
Maintainers
Readme
ms-nestjs-eureka is a NestJS module that provides an integration
with eureka-js-client
Getting Started
You need to import the EurekaModule in your application:
EurekaModule.forRoot({
eureka: {
host: 'eureka-service',
port: 8761,
registryFetchInterval: 1000,
servicePath: '/eureka/apps/',
maxRetries: 3,
//debug: true
},
service: {
name: 'my-service',
port: 8080,
},
})Use with NestJS Microservices
ClientsModule.registerAsync([
{
name: 'MS_SERVICE1',
imports: [EurekaModule],
useFactory: async (discoveryService: DiscoveryService) => {
const instance = await discoveryService.getInstanceByAppId('my-service');
return {
transport: Transport.TCP,
options: {
host: instance.hostName,
port: instance.port,
},
};
},
inject: [DiscoveryService],
},
])