UNPKG

inceptum

Version:

hipages take on the foundational library for enterprise-grade apps written in NodeJS

25 lines 1.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // tslint:disable:prefer-function-over-method const BaseSingletonDefinition_1 = require("../ioc/objectdefinition/BaseSingletonDefinition"); const PostgresClient_1 = require("./PostgresClient"); class PostgresPlugin { getName() { return this.name; } willStart(app) { if (!app.hasConfig('postgres')) { throw new Error('PostgresPlugin has been registered but could not find config using key "postgres"'); } const context = app.getContext(); const confs = context.getConfig('postgres'); Object.keys(confs).forEach((key) => { const clientSingleton = new BaseSingletonDefinition_1.BaseSingletonDefinition(PostgresClient_1.PostgresClient, key); clientSingleton.setPropertyByValue('name', key); clientSingleton.setPropertyByValue('configuration', confs[key]); context.registerSingletons(clientSingleton); }); } } exports.default = PostgresPlugin; //# sourceMappingURL=PostgresPlugin.js.map