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 🙏

© 2025 – Pkg Stats / Ryan Hefner

api-websocket-bridge

v1.0.5

Published

API WebSocket Bridge is a Node.js application that provides a WebSocket server for real-time communication. It allows clients to connect and exchange data using the WebSocket protocol

Readme

API WebSocket Bridge

API WebSocket Bridge is a Node.js application designed to be run in a Docker container. It constantly refreshes an API at a set interval and distributes WebSocket (WSS) events to connected clients.

Prerequisites

Before running the API WebSocket Bridge, make sure you have the following:

  • Docker installed on your machine.

Getting Started

To run the API WebSocket Bridge in a Docker container, follow these steps:

  1. Clone this repository to your local machine.
  2. Navigate to the project directory.
cd websocket-driver
  1. Configure the API WebSocket Bridge by editing the config.json file located in the config directory. Refer to the 'Configuration' section below for details on how to customize the configuration based on your requirements and the API you are working with.

  2. Build the Docker image.

docker build -t websocket-driver .
  1. Run the Docker container, exposing the necessary port and providing the required volume mounts.
docker run -d -p 8080:8080 --name websocket-container \
  -v /path/to/cert/fullchain.pem:/app/cert/fullchain.pem \
  -v /path/to/cert/privkey.pem:/app/cert/privkey.pem \
  -v /path/to/config:/app/config \
  websocket-driver

Make sure to replace /path/to/cert with the path to your SSL certificate and key files, and /path/to/config with the path to your config.json file.

Configuration

The WebSocketDriver application relies on a configuration file (config.json) to specify various settings. Below is an example configuration that corresponds to the example response from Salty Bet's API:

{
  "certPath": "/app/cert/fullchain.pem",
  "keyPath": "/app/cert/privkey.pem",
  "port": 8080,
  "updateInterval": 5000,
  "apiUrl": "https://www.saltybet.com/state.json",
  
  "events": {
    "teamNamesChange": {
      "emitEvent": "teamNamesChange",
      "params": ["p1name", "p2name"] 
    },
    "betAmountChange": {
      "emitEvent": "betAmountChange",
      "params": ["p1total", "p2total"]
    },
    "statusChange": {
      "emitEvent": "statusChange",
      "params": ["status"]
    },
    "alertChange": {
      "emitEvent": "alertChange",
      "params": ["alert"]
    },
    "remainingChange": {
      "emitEvent": "remainingChange",
      "params": ["remaining"]
    }
  }
}
  • "certPath" and "keyPath" specify the file paths for the SSL certificate and private key respectively.
  • "port" defines the port number on which the WebSocket server will run.
  • "updateInterval" determines the interval (in milliseconds) at which the API will be checked for updates.
  • "apiUrl" specifies the URL of the API that provides the match information. In this case, it is Salty Bet's API endpoint (https://www.saltybet.com/state.json).
  • "events" contains a mapping of event types to their corresponding configuration.

The example response from Salty Bet's API:

{
  "p1name": "Upset chieshen",
  "p2name": "Brunestud arcueid",
  "p1total": "0",
  "p2total": "0",
  "status": "open",
  "alert": "",
  "x": 0,
  "remaining": "78 more matches until the next tournament!"
}

The configuration defines five events with their respective emitEvent names and associated parameters. These events allow you to subscribe to specific changes in the API response:

  • teamNamesChange: Triggers when the names of the players change ("p1name" or "p2name").
  • betAmountChange: Triggers when the total bet amounts change ("p1total" or "p2total").
  • statusChange: Triggers when the match status changes ("status").
  • alertChange: Triggers when there is an alert or message change ("alert").
  • remainingChange: Triggers when the number of matches remaining changes ("remaining").

These events provide flexibility in handling specific updates and allow you to emit WebSocket events accordingly.

Please make sure to modify the configuration file (config.json) according to your requirements and the API you are working with.

Development

To set up the project for development, follow these steps:

  1. Clone this repository to your local machine.
  2. Navigate to the project directory.
cd api-websocket-bridge
  1. Install the required dependencies.
npm install
  1. Start the API WebSocket Bridge.
npm start

The API WebSocket Bridge will now be running on your local machine.

License

This project is licensed under the Apache 2.0.

Acknowledgements

This project makes use of the following packages:

We would like to express our gratitude to the authors and maintainers of these packages for their valuable contributions to the open-source community.