1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 |
|
4 | const BaseSingletonDefinition_1 = require("../ioc/objectdefinition/BaseSingletonDefinition");
|
5 | const SqsWorker_1 = require("./SqsWorker");
|
6 | class SqsWorkerPlugin {
|
7 | constructor() {
|
8 | this.name = 'SqsWorkerPlugin';
|
9 | }
|
10 | getName() {
|
11 | return this.name;
|
12 | }
|
13 | willStart(app) {
|
14 | if (!app.hasConfig('SqsWorker')) {
|
15 | throw new Error('SQSWorkerPlugin has been registered but could not find config using key "SqsWorker"');
|
16 | }
|
17 | const context = app.getContext();
|
18 | const confs = context.getConfig('SqsWorker');
|
19 | Object.keys(confs).forEach((key) => {
|
20 | const clientSingleton = new BaseSingletonDefinition_1.BaseSingletonDefinition(SqsWorker_1.SqsWorker, key);
|
21 | clientSingleton.constructorParamByValue(confs[key]);
|
22 | clientSingleton.constructorParamByValue(key);
|
23 | clientSingleton.setPropertyByRef('handler', confs[key]['handlerObject']);
|
24 | context.registerSingletons(clientSingleton);
|
25 | });
|
26 | }
|
27 | }
|
28 | exports.default = SqsWorkerPlugin;
|
29 |
|
\ | No newline at end of file |