Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

routexjs/routex-websocket

Repository files navigation

Routex WebSocket npm Travis CI Codecov

WebSockets for Routex.

Documentation - GitHub

Example

Install:

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

Setup your app:

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, include current Node versions.

Please file feature requests and bugs at the issue tracker.