Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jameskyburz/aws-lambda-ws-server
aws lambda websocket server.
https://github.com/jameskyburz/aws-lambda-ws-server
apigateway aws lambda websocket ws
Last synced: 12 days ago
JSON representation
aws lambda websocket server.
- Host: GitHub
- URL: https://github.com/jameskyburz/aws-lambda-ws-server
- Owner: JamesKyburz
- License: apache-2.0
- Created: 2019-01-09T14:23:14.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-04-29T21:33:51.000Z (over 3 years ago)
- Last Synced: 2024-10-25T17:14:27.455Z (19 days ago)
- Topics: apigateway, aws, lambda, websocket, ws
- Language: JavaScript
- Homepage: https://npm.im/aws-lambda-ws-server
- Size: 134 KB
- Stars: 39
- Watchers: 2
- Forks: 2
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# aws-lambda-ws-server
[![js-standard-style](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/feross/standard)
[![build status](https://api.travis-ci.org/JamesKyburz/aws-lambda-ws-server.svg)](https://travis-ci.org/JamesKyburz/aws-lambda-ws-server)
[![downloads](https://img.shields.io/npm/dm/aws-lambda-ws-server.svg)](https://npmjs.org/package/aws-lambda-ws-server)AWS Lambda Websocket Server.
### usage
```javascript
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](LICENSE)