1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 |
|
4 | const BaseSingletonDefinition_1 = require("../ioc/objectdefinition/BaseSingletonDefinition");
|
5 | const PostgresClient_1 = require("./PostgresClient");
|
6 | class 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 | }
|
24 | exports.default = PostgresPlugin;
|
25 |
|
\ | No newline at end of file |