UNPKG

1.09 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3// tslint:disable:prefer-function-over-method
4const BaseSingletonDefinition_1 = require("../ioc/objectdefinition/BaseSingletonDefinition");
5const PostgresClient_1 = require("./PostgresClient");
6class PostgresPlugin {
7 getName() {
8 return this.name;
9 }
10 willStart(app) {
11 if (!app.hasConfig('postgres')) {
12 throw new Error('PostgresPlugin has been registered but could not find config using key "postgres"');
13 }
14 const context = app.getContext();
15 const confs = context.getConfig('postgres');
16 Object.keys(confs).forEach((key) => {
17 const clientSingleton = new BaseSingletonDefinition_1.BaseSingletonDefinition(PostgresClient_1.PostgresClient, key);
18 const config = Object.assign({}, confs[key], { name: key });
19 clientSingleton.constructorParamByValue(config);
20 context.registerSingletons(clientSingleton);
21 });
22 }
23}
24exports.default = PostgresPlugin;
25//# sourceMappingURL=PostgresPlugin.js.map
\No newline at end of file