aws-post-to-connection

post to a connected websocket client.
usage
const PostToConnection = require('aws-post-to-connection')
const postToSameGateway = PostToConnection(event)
await postToSameGateway({ message: 'hello' }, 'connectionId')
const postToAnotherGateway = PostToConnection({
stage: 'stage',
domainName: '<apiId>.execute-api.<region>.amazonaws.com'
})
await postToConnection({ message: 'hello' }, 'connectionId')
const postToLocalhost = PostToConnection({
stage: 'stage',
domainName: 'localhost',
secure: false
})
await postToConnection({ message: 'hello' }, 'connectionId')
Works locally and in a lambda function.
license
Apache License, Version 2.0