npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@axiljs/websocket

v0.4.2

Published

AxilJS RFC 6455 WebSocket server with rooms and broadcasting

Readme

@axiljs/websocket

RFC 6455 WebSocket server with rooms, broadcasting, and ping/pong.

Part of the AxilJS ecosystem.

Install

npm install @axiljs/websocket

Usage

import { WSServer } from '@axiljs/websocket'

const wss = new WSServer(app.getServer(), { path: '/ws' })

wss.on('connection', (client) => {
  wss.join(client, 'general')
  client.sendJSON({ type: 'welcome', id: client.id })

  client.on('message', (data) => {
    wss.toRoomJSON('general', { from: client.id, data: data.toString() })
  })
})

Limits and protocol enforcement

new WSServer(server, {
  path: '/ws',
  maxPayload: 16 * 1024 * 1024, // default 16 MiB, per frame and per reassembled message
  closeTimeoutMs: 5000,         // destroy the socket if the peer doesn't answer our close frame
  heartbeatIntervalMs: 30000    // ping interval; 0 disables
})
  • Oversized frames/messages close with 1009 (checked on the declared length, before the payload is buffered).
  • RFC 6455 violations close with 1002: unmasked client frames, RSV bits, unknown opcodes, control frames over 125 bytes or fragmented, bad continuation frames, invalid close codes. Invalid UTF-8 in text frames closes with 1007.
  • Heartbeat: a client that hasn't answered the previous ping with a pong by the next tick is terminated (close fires with 1006).
  • Upgrades for other paths are left alone when the http server has other upgrade listeners (e.g. several WSServers on different paths sharing one server). When this WSServer is the only upgrade listener, they get 404 Not Found and the socket is closed, so clients don't hang. A non-WebSocket upgrade on the configured path gets 400.
  • wss.close(code?, reason?) closes every client; client.terminate() drops one without a handshake.

Connecting from a client

This package is server-only: WSClient is the server-side wrapper for an accepted connection, not an outbound client. To connect, use Node's global WebSocket (Node ≥ 22), the browser WebSocket, or any RFC 6455 client:

const ws = new WebSocket('ws://localhost:3000/ws')
ws.addEventListener('open', () => ws.send('hello'))
ws.addEventListener('message', (e) => console.log('got', e.data))
ws.addEventListener('close', (e) => console.log('closed', e.code))
ws.addEventListener('error', (e) => console.error(e))

Full docs: github.com/SyntaxilitY/AxilJS