diff --git a/index.js b/index.js index e5c54ec..a21da44 100644 --- a/index.js +++ b/index.js @@ -12,11 +12,11 @@ const resolve = async name => { } } -const send = (topic, subject, message) => - sns.publish({ TopicArn: topic, Subject: subject, Message: message }).promise() +const send = (topic, message, options) => + sns.publish({ TopicArn: topic, Message: message, ...options }).promise() -export default async (channel, subject, payload = {}) => { +export default async (channel, payload = {}, options = {}) => { const topic = await resolve(channel) const message = JSON.stringify(payload) - return send(topic, subject, message) + return send(topic, message, options) } diff --git a/readme.md b/readme.md index 91f5e16..e4f9a6e 100644 --- a/readme.md +++ b/readme.md @@ -16,14 +16,14 @@ $ npm install @nutshelllab/sns-messenger const send = require('sns-messenger'); (async () => { - await send('my-topic', 'subject', { foo: 'bar' }); + await send('my-topic', { foo: 'bar' }, { Subject: 'foobar' }); }) ``` ## API -### snsMessenger(topic, subject, payload) +### snsMessenger(topic, payload, options) #### topic @@ -31,17 +31,17 @@ Type: `string` SNS topic to send message -#### subject +##### payload -Type: `string` +Type: `Object` -Message subject +Message payload -##### payload +##### options Type: `Object` -Message payload +Extra AWS SNS parameters, see [AWSJavaScriptSDK documentation](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SNS.html#publish-property) ## License