Skip to content

Commit 731c94b

Browse files
authored
Update sqs.controller.ts - Removing use of Promise
1 parent a171664 commit 731c94b

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

src/api/integrations/event/sqs/sqs.controller.ts

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,29 @@ export class SqsController extends EventController implements EventControllerInt
1717
super(prismaRepository, waMonitor, configService.get<Sqs>('SQS')?.ENABLED, 'sqs');
1818
}
1919

20-
public init(): void {
20+
public async init(): Promise<void> {
2121
if (!this.status) {
2222
return;
2323
}
2424

25-
new Promise<void>(async (resolve) => {
26-
const awsConfig = configService.get<Sqs>('SQS');
25+
const awsConfig = configService.get<Sqs>('SQS');
2726

28-
this.sqs = new SQS({
29-
credentials: {
30-
accessKeyId: awsConfig.ACCESS_KEY_ID,
31-
secretAccessKey: awsConfig.SECRET_ACCESS_KEY,
32-
},
33-
34-
region: awsConfig.REGION,
35-
});
27+
this.sqs = new SQS({
28+
credentials: {
29+
accessKeyId: awsConfig.ACCESS_KEY_ID,
30+
secretAccessKey: awsConfig.SECRET_ACCESS_KEY,
31+
},
3632

37-
this.logger.info('SQS initialized');
33+
region: awsConfig.REGION,
34+
});
3835

39-
const sqsConfig = configService.get<Sqs>('SQS');
40-
if (this.sqs && sqsConfig.GLOBAL_ENABLED) {
41-
const sqsEvents = Object.keys(sqsConfig.EVENTS).filter(e => sqsConfig.EVENTS[e]);
42-
await this.saveQueues(sqsConfig.GLOBAL_PREFIX_NAME, sqsEvents, true);
43-
}
36+
this.logger.info('SQS initialized');
4437

45-
resolve();
46-
});
38+
const sqsConfig = configService.get<Sqs>('SQS');
39+
if (this.sqs && sqsConfig.GLOBAL_ENABLED) {
40+
const sqsEvents = Object.keys(sqsConfig.EVENTS).filter(e => sqsConfig.EVENTS[e]);
41+
await this.saveQueues(sqsConfig.GLOBAL_PREFIX_NAME, sqsEvents, true);
42+
}
4743
}
4844

4945
private set channel(sqs: SQS) {

0 commit comments

Comments
 (0)