apf-node-common 1.0.111 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apf-node-common",
3
- "version": "1.0.111",
3
+ "version": "2.0.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -3,16 +3,26 @@ const AWS = require('aws-sdk');
3
3
 
4
4
  const environment = (process.env.NODE_ENVIRONMENT || 'Test');
5
5
  const awsRegion = (process.env.AWS_DEFAULT_REGION || 'us-east-2');
6
- const awsAccountNumber = (process.env.AWS_ACCOUNT_NUMBER || '441138747230');
6
+ const awsAccountNumber = (process.env.AWS_ACCOUNT_NUMBER);
7
7
  AWS.config.update({ region: awsRegion });
8
8
  AuditLogger = require("../../auditlog/AuditLogger");
9
9
  var sns = new AWS.SNS({apiVersion: '2010-03-31'});
10
10
 
11
11
  module.exports = {
12
-
13
12
  async publish(topic, subject, message,messageAttributes) {
14
13
  try{
15
- const topicARN = `arn:aws:sns:${awsRegion}:${awsAccountNumber}:${environment}-${topic}`;
14
+ let topicARN;
15
+ if(awsAccountNumber)
16
+ {
17
+ topicARN = `arn:aws:sns:${awsRegion}:${awsAccountNumber}:${environment}-${topic}`;
18
+ }
19
+ else
20
+ {
21
+ log.info("Calling CreateTopic" + topicARN);
22
+ const topicName = `${environment}-${topic}`;
23
+ var response = await sns.createTopic({ Name: topicName }).promise();
24
+ topicARN = response.TopicArn;
25
+ }
16
26
  log.info("Topic ARN is " + topicARN);
17
27
 
18
28
  const snsParameters = {