UNPKG

ms-nestjs-eureka

Version:

A NestJS module that integrate eureka-js-client

47 lines (40 loc) 996 B
`ms-nestjs-eureka` is a [NestJS](https://nestjs.com/) module that provides an integration with [eureka-js-client](https://github.com/jquatier/eureka-js-client#eureka-js-client) ## Getting Started You need to import the `EurekaModule` in your application: ```js 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 ```js 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], }, ]) ```