Created
January 29, 2023 01:11
-
-
Save arantesxyz/419a66fcb079609883be76c9bf8c4d3f to your computer and use it in GitHub Desktop.
NodeJs AWS SNS Sender
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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