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

@pingpal/relay

v0.2.0

Published

Self-hostable WebSocket relay for PingPal — rooms, presence, and ping routing, all in memory.

Downloads

201

Readme

@pingpal/relay

The self-hostable WebSocket relay for PingPal. It routes pings between teammates who aren't on the same LAN and tracks who's online — and it stores nothing long-term. All state (rooms, presence) lives in memory and disappears when connections close.

The relay is only needed for remote peers; same-LAN teammates connect directly via mDNS. You only run this if you want to talk to people off your network.

What it does

  • Rooms by code. A client opens a socket and sends a hello with its roomCode + handle. The room code is the lightweight shared secret — peers only ever see and message others in the same room.
  • Presence. Maintains an in-memory roster per room and broadcasts presence updates on join, leave, and status change. Peers go idle after ~60s of no activity and vanish on disconnect.
  • Ping routing. to: null broadcasts to everyone else in the room; to: "handle" delivers only to that handle's connection(s). The sender always gets an ack. The relay re-stamps from with the authenticated handle so it can't be spoofed.
  • Defensive validation. Malformed JSON, non-envelope frames, and text over the 90-char cap are rejected with an error envelope. Each connection is rate-limited with a token bucket.

Run it

# From a clean checkout of the monorepo:
pnpm install
pnpm --filter @pingpal/relay build

# Start it (PORT defaults to 8787):
node packages/relay/dist/bin.js
# or, once installed: pingpal-relay

Environment variables: PORT (default 8787) and HOST (default all interfaces).

Point clients at your instance with PINGPAL_RELAY=ws://your-host:8787.

Deploy

Docker

Build from the repo root (the workspace must be in the build context):

docker build -f packages/relay/Dockerfile -t pingpal-relay .
docker run -p 8787:8787 pingpal-relay

Fly.io

fly launch --no-deploy --copy-config --dockerfile packages/relay/Dockerfile
fly deploy --config packages/relay/fly.toml --dockerfile packages/relay/Dockerfile

Rename app in fly.toml first. Clients then use PINGPAL_RELAY=wss://<app>.fly.dev.

Railway / Render

Point either platform at packages/relay/Dockerfile and let it expose $PORT (8787). No other configuration is required.

Programmatic use

import { startRelay } from "@pingpal/relay";

const relay = await startRelay({ port: 8787 });
console.log(`listening on :${relay.port}`);
// …later
await relay.close();

startRelay(opts) accepts port, host, heartbeatMs, idleAfterMs, rateCapacity, and rateRefillPerSec. Use port: 0 for an ephemeral port (handy in tests).

Manual smoke test

Two simulated clients exchanging a ping is exactly what the vitest integration test does (pnpm --filter @pingpal/relay test). To do it by hand, start the relay and connect with any WebSocket client, sending newline-delimited JSON:

{"type":"hello","roomCode":"demo-room-1234","handle":"alice","faceId":"fox","clientVersion":"manual"}
{"type":"ping","id":"1","from":"alice","to":null,"text":"hello room","ts":0}