ultimate-express-ws
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

Ultimate-Express-WS (alpha)

Drop in replacement for Express-WS library in favour of Ultimate-WS over the traditional WS library.

Makes it easy to add Websocket Endpoints to your Express app while using uWebsockets under the hood through Ultimate-WS.

Checkout

*NOTE If you are already using bun, these libraries will fail (trust me lol)! You have to uninstall bun first and switch to Node JS for these libraries to work.

Main Changes:

  • leverages Ultimate-WS features
  • Type safety
  • Support Subprotocols (like Graphql) [untested]
  • Middleware support + Map Based route storage
  • added custom getRoutes() to view all Websocket endpoints (for debugging)

Installation

npm i ultimate-express-ws

Example With Ultimate-Express

const express = require("ultimate-express"); // or express 
const expressApp = express();
import handleWebsocket from '/services/handleWebsocket.ts'
import {UltimateExpressWS} from 'ultimate-express-ws'

// EXPRESSWS
// export const appInstance = ExpressWS(expressApp);

// Ultimate-Express-WS
export const appInstance = UltimateExpressWS(expressApp, undefined, 
 { 
    wsOptions: {
    perMessageDeflate: true,
    clientTracking: true,
    autoPong: true, 
  }
});
const app = appInstance.app

// Add your websocket endpoint
app.ws('/ws', handleWebsocket)

// appInstance.getRoutes() -- Lists all for your ws routes
// appInstance.getWss() -- the main WebSocket server
// appInstance.app - express app



** This is an early release so use it at your own risk **

Readme

Keywords

none

Package Sidebar

Install

npm i ultimate-express-ws

Weekly Downloads

70

Version

0.2.0

License

ISC

Unpacked Size

14 kB

Total Files

6

Last publish

Collaborators

  • phdking123