# @routex/websocket

> WebSockets for Routex

Latest version **0.1.0** (published 2020-04-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install @routex/websocket
pnpm add @routex/websocket
yarn add @routex/websocket
bun add @routex/websocket
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2020-04-10 |
| First published | 2019-05-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 2 |
| Unpacked size | 8.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Charles Crete |
| Maintainers | cretezy |
| Keywords | routex, websocket, ws |

## Links

- npm: https://www.npmjs.com/package/@routex/websocket
- Repository: https://github.com/routexjs/routex-websocket
- Homepage: https://routex.js.org/docs/packages/websocket
- npm.io page: https://npm.io/package/@routex/websocket

## Dependencies (2)

- [ws](https://npm.io/package/ws.md) ^7.2.3
- [@types/ws](https://npm.io/package/@types/ws.md) ^7.2.3

## 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.0 (latest) — 2020-04-10
- 0.0.6 — 2019-05-25
- 0.0.5 — 2019-05-23
- 0.0.4 — 2019-05-23
- 0.0.3 — 2019-05-23

## README

# Routex WebSocket [![npm](https://img.shields.io/npm/v/@routex/websocket.svg)](https://www.npmjs.com/package/@routex/websocket) [![Travis CI](https://img.shields.io/travis/com/routexjs/routex-websocket.svg)](https://travis-ci.com/routexjs/routex-websocket) [![Codecov](https://img.shields.io/codecov/c/github/routexjs/routex-websocket.svg)](https://codecov.io/gh/routexjs/routex-websocket) [![Greenkeeper badge](https://badges.greenkeeper.io/routexjs/routex-websocket.svg)](https://greenkeeper.io/)

WebSockets for [Routex](https://www.npmjs.com/package/routex).

[Documentation](https://routex.js.org/docs/packages/websocket) - [GitHub](https://github.com/routexjs/routex-websocket)

## Example

Install:

```bash
yarn add @routex/websocket
# or
npm add @routex/websocket
```

Setup your app:

```js
const { Routex, TextBody } = require("routex");
const websocket = require("@routex/websocket");

const port = process.env.PORT || 3000;
const app = new Routex();

app.appMiddleware(websocket());

// Must be a GET request.
app.get(
  "/",
  websocket.socketHandler((socket) => {
    // Echo server
    socket.on("message", (data) => {
      socket.send("You said: " + data);
    });
  })
);

app.listen(port).then(() => console.log(`Listening on ${port}`));
```

## Support

We support all currently active and maintained [Node LTS versions](https://github.com/nodejs/Release),
include current Node versions.

Please file feature requests and bugs at the [issue tracker](https://github.com/routexjs/routex-websocket/issues).

---
_Source: https://npm.io/package/@routex/websocket · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
