inceptum
Version:
hipages take on the foundational library for enterprise-grade apps written in NodeJS
28 lines • 1.21 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
// tslint:disable:prefer-function-over-method
const BaseSingletonDefinition_1 = require("../ioc/objectdefinition/BaseSingletonDefinition");
const ElasticsearchClient_1 = require("./ElasticsearchClient");
class ElasticsearchPlugin {
constructor() {
this.name = 'ElasticsearchPlugin';
}
getName() {
return this.name;
}
willStart(app) {
if (!app.hasConfig('elasticsearch')) {
throw new Error('ElasticsearchPlugin has been registered but could not find config using key "elasticsearch"');
}
const context = app.getContext();
const confs = context.getConfig('elasticsearch');
Object.keys(confs).forEach((key) => {
const clientSingleton = new BaseSingletonDefinition_1.BaseSingletonDefinition(ElasticsearchClient_1.ElasticsearchClient, key);
clientSingleton.setPropertyByValue('name', key);
clientSingleton.setPropertyByValue('configuration', confs[key]);
context.registerSingletons(clientSingleton);
});
}
}
exports.default = ElasticsearchPlugin;
//# sourceMappingURL=ElasticsearchPlugin.js.map