Skip to content

Instantly share code, notes, and snippets.

@arantesxyz
Created January 29, 2023 01:11
Show Gist options
  • Select an option

  • Save arantesxyz/419a66fcb079609883be76c9bf8c4d3f to your computer and use it in GitHub Desktop.

Select an option

Save arantesxyz/419a66fcb079609883be76c9bf8c4d3f to your computer and use it in GitHub Desktop.
NodeJs AWS SNS Sender
const AWS = require("aws-sdk");
AWS.config.update({
region: process.env.AWS_REGION,
});
class SNSSender {
constructor() {
this.provider = new AWS.SNS();
}
sendMessage(topicArn, message) {
return this.provider.publish({
Message: typeof message === 'string' ? message : JSON.stringify(message),
TopicArn: topicArn
}).promise()
}
}
module.exports = new SNSSender()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment