# aws-lambda-ws-server

> websocket server for aws lambda and local development

Latest version **0.1.21** (published 2020-11-20) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install aws-lambda-ws-server
pnpm add aws-lambda-ws-server
yarn add aws-lambda-ws-server
bun add aws-lambda-ws-server
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.21 |
| Published | 2020-11-20 |
| First published | 2019-01-09 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 29 KB |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 40 |
| Author | James Kyburz |
| Maintainers | jameskyburz |
| Keywords | aws, lambda, websocket, api-gateway |

## Links

- npm: https://www.npmjs.com/package/aws-lambda-ws-server
- Repository: https://github.com/jameskyburz/aws-lambda-ws-server
- Homepage: https://github.com/jameskyburz/aws-lambda-ws-server#readme
- Issues: https://github.com/jameskyburz/aws-lambda-ws-server/issues
- npm.io page: https://npm.io/package/aws-lambda-ws-server

## Dependencies (3)

- [ws](https://npm.io/package/ws.md) 7.4.0
- [is-lambda](https://npm.io/package/is-lambda.md) 1.0.1
- [aws-post-to-connection](https://npm.io/package/aws-post-to-connection.md) ^0.1.21

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.1.21 (latest) — 2020-11-20
- 0.1.20 — 2020-03-30
- 0.1.18 — 2020-02-15
- 0.1.17 — 2020-01-04
- 0.1.16 — 2020-01-04
- 0.1.12 — 2020-01-03
- 0.1.11 — 2020-01-03
- 0.1.7 — 2020-01-02
- 0.1.4 — 2020-01-02
- 0.1.2 — 2019-02-01
- 0.1.1 — 2019-01-13
- 0.1.0 — 2019-01-13
- 0.0.5 — 2019-01-10
- 0.0.4 — 2019-01-10
- 0.0.3 — 2019-01-10
- … 2 more at https://npm.io/package/aws-lambda-ws-server/versions

## 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)

<a href="https://asciinema.org/a/291478?autoplay=1&speed=1.5&size=medium&preload=1"><img src="https://asciinema.org/a/291478.svg" width="480"></a>

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)

---
_Source: https://npm.io/package/aws-lambda-ws-server · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
