sns-listen

Handle incoming AWS SNS messages

Usage no npm install needed!

<script type="module">
  import snsListen from 'https://cdn.skypack.dev/sns-listen';
</script>

README

Amazon AWS SNS endpoint

Version npmnpm DownloadsDependenciesTips

sns-listen handles incoming messages from AWS SNS (Simple Notification Service). It will automaticly confirms subscriptions and emit notifications.

Example

const snsListen = require('sns-listen')

const sns = snsListen()

sns.on('notification', (message) => {
  console.log('got notification', message)
})

sns.on('subscribed', () => {
  console.log('We are now subscribed')
})

sns.on('unsubscribed', () => {
  console.log('Got UnsubscribeConfirmation')
})

sns.on('error', (err) => {
  console.error('Something went wrong', err)
  process.exit()
})

sns.listen(9000)

Use with Express

const express = require('express')
const snsListen = require('sns-listen')

const app = express()

app.post('/sns', snsListen((message) => {
  console.log('got notification', message)
}))

app.listen(9000)

Install

npm install -S sns-listen

License

MIT