O'Reilly logo

TypeScript Microservices by Parth Ghiya

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Discovering with Eureka server

In this section, we will discover our register service in another microservice. We will be getting a response from that service without knowing the service address or hardcoding the location anywhere. Copy the structure of first-microservice from Chapter 2, Gearing up for the Journey. As we will need Eureka client everywhere, we will create EurekaService.ts. You can find the full source code in the eureka/eureka-service-discovery/src folder of the project.

Let's take a look at the steps to discover our registered service:

  1. Create a file called EurekaService.ts, and create static methods for initializing clients:
static getClient(): Eureka{  if (!this._client) {    this._client = new Eureka({ instance: {}, //set ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required