UNPKG

express-gateway-service-registry

Version:

With self-registration, each microservice is responsible for adding itself to the gateway when it comes online.

43 lines (32 loc) 1.15 kB
# express-gateway-service-registry ## Installation Install GatewayServiceRegistryComponent using `npm`; ```sh $ [npm install | yarn add] express-gateway-service-registry ``` ## Basic Use Configure and load GatewayServiceRegistryComponent in the application constructor as shown below. ```ts import {GatewayServiceRegistryComponent, Config,GatewayServiceRegistryComponentOptions, DEFAULT_SERVICE_REGISTRY_OPTIONS} from 'express-gateway-service-registry'; // ... export class MyApplication extends BootMixin(ServiceMixin(RepositoryMixin(RestApplication))) { constructor(options: ApplicationConfig = {}) { const opts: GatewayServiceRegistryComponentOptions = DEFAULT_SERVICE_REGISTRY_OPTIONS; this.configure(GatewayServiceRegistryComponentBindings.COMPONENT).to(opts); // Put the configuration options here }); this.bind<Config>(GatewayServiceRegistryComponentBindings.CONFIG).to({ name: "test-micro", path: "/test-micro/*", host: "srv.mydomain.com", backend: { url: "http://localhost:3001" } }); this.component(GatewayServiceRegistryComponent); // ... } // ... } ```