express-gateway-service-registry
v2.5.0
Published
With self-registration, each microservice is responsible for adding itself to the gateway when it comes online.
Downloads
47
Maintainers
Readme
express-gateway-service-registry
Installation
Install GatewayServiceRegistryComponent using npm
;
$ [npm install | yarn add] express-gateway-service-registry
Basic Use
Configure and load GatewayServiceRegistryComponent in the application constructor as shown below.
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);
// ...
}
// ...
}