0.1.21 • Published 3 years ago

aws-lambda-ws-server v0.1.21

Weekly downloads
7
License
Apache-2.0
Repository
github
Last release
3 years ago

aws-lambda-ws-server

js-standard-style build status downloads

AWS Lambda Websocket Server.

usage

const ws = require('aws-lambda-ws-server')
exports.handler = ws(
  ws.handler({
    async connect ({ id }) {
      console.log('connection %s', id)
      return { statusCode: 200 }
    },
    async disconnect ({ id }) {
      console.log('disconnect %s', id)
      return { statusCode: 200 }
    },
    async default ({ message, id }) {
      console.log('default message', message, id)
      return { statusCode: 200 }
    },
    async message ({ message, id, context }) {
      const { postToConnection } = context
      console.log('message', message, id)
      await postToConnection({ message: 'echo' }, id)
      return { statusCode: 200 }
    }
  })
)

Works locally and in a lambda function.

license

Apache License, Version 2.0

0.1.21

3 years ago

0.1.20

4 years ago

0.1.18

4 years ago

0.1.16

4 years ago

0.1.17

4 years ago

0.1.12

4 years ago

0.1.11

4 years ago

0.1.7

4 years ago

0.1.4

4 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago