UNPKG

inceptum

Version:

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

25 lines 1.1 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); const config = Object.assign(Object.assign({}, confs[key]), { name: key }); clientSingleton.constructorParamByValue(config); context.registerSingletons(clientSingleton); }); } } exports.default = PostgresPlugin; //# sourceMappingURL=PostgresPlugin.js.map