aws-post-to-connection

0.1.21 • Public • Published

aws-post-to-connection

js-standard-style build status downloads

post to a connected websocket client.

usage

const PostToConnection = require('aws-post-to-connection')

// post to same gateway
const postToSameGateway = PostToConnection(event)
await postToSameGateway({ message: 'hello' }, 'connectionId')

// post to another gateway
const postToAnotherGateway = PostToConnection({
  stage: 'stage',
  domainName: '<apiId>.execute-api.<region>.amazonaws.com'
})
await postToConnection({ message: 'hello' }, 'connectionId')

// post to local websocket server
const postToLocalhost = PostToConnection({
  stage: 'stage',
  domainName: 'localhost',
  port: 5000,
  secure: false
})
await postToConnection({ message: 'hello' }, 'connectionId')

Works locally and in a lambda function.

license

Apache License, Version 2.0

Package Sidebar

Install

npm i aws-post-to-connection

Weekly Downloads

222

Version

0.1.21

License

Apache-2.0

Unpacked Size

25.5 kB

Total Files

4

Last publish

Collaborators

  • jameskyburz