Skip to content

Commit

Permalink
Removed subject param + Added options param
Browse files Browse the repository at this point in the history
  • Loading branch information
BlitzBanana committed Jul 25, 2018
1 parent 283746f commit 4eeed86
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
14 changes: 7 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@ $ 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

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
Expand Down

0 comments on commit 4eeed86

Please sign in to comment.