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

fwd-server-websocket

v0.0.11

Published

http server that routes requested urls via websocket to client(s) that generates responses to the original requests

Readme

fwd-server-websocket

quick and dirty local http server that routes requested urls via websocket to a client that generates responses to the original requests

use ipWhitelistRequesters and ipWhitelistSocketClients to limit the IP addresses that can request and generate responses respectively -- remember, any client that connects to the websocket can 'intercept' and generate responses!

this is meant to allow us to use cheap/minimal public-facing servers ["free tier" etc] while offloading processing for a request to a local machine, without opening ports or directly exposing the local machine.

Installation

npm i fwd-server-websocket

Usage

var fsw = require('fwd-server-websocket');

//defaults shown [except for magicWord]
var port = 3000;
var pollingTimeMs = 10; //poll to wait for response generated by websocket 
var magicWord = "hereWeGo"; //default is blank "" -- rejects requests that do not have the magic word in the URL
var contentTypeReturned = "application/json";
//IPs that are allowed to make requests from the server
var ipWhitelistRequesters =  ['::ffff:127.0.0.1','::ffff:192.168.0.1','127.0.0.1', '192.168.0.1']; //set to [] to allow ALL ips [not recommended!]
//IPs that are allowed to generate responses for the server
var ipWhitelistSocketClients =  ['::ffff:127.0.0.1','::ffff:192.168.0.1','127.0.0.1', '192.168.0.1']; //set to [] to allow ALL ips [not recommended!]
fsw.runServer(port, magicWord, pollingTimeMs, contentTypeReturned, ipWhitelistRequesters, ipWhitelistSocketClients); //run http server on port 3000

//now we can do the following in a different file/ on a different machine etc. or within the same file for this example.

// run websocket client that connects to the server,
// processes incoming msgs from requests, then serves
// the results to be return to the original requester

var defaultMsgRunner = function(message, ws){  //default function echos data wrapped in an object
    // Process the received message
      console.log('Received message:', message);
      const message2 = { messageOrig: JSON.parse(message)};
      ws.send(JSON.stringify(message2));
}

var defaultUrl = "ws://localhost:3000";
fsw.runClient(defaultUrl, defaultMsgRunner);

//now we can make a GET request with axios. 
// defaultMsgRunner will generate the response! 
var axios = require('axios');

//now anytime a GET request to the server is made, the function above is called to process the response
axios.get('http://localhost:3000/hereWeGo_hereIsMyMsg')
  .then(response => {
    console.log(`Status Code: ${response.status}`); //200
    console.log(`Response Body:`,response.data); //{ messageOrig: { data: 'hereWeGo_hereIsMyMsg' } }
  })
  .catch(error => {
    console.error(`An error occurred: ${error}`);
  });

//this request gets rejected with a 404 because it is missing the magicWord
axios.get('http://localhost:3000/hereWeDontGo_hereIsMyMsg')
  .then(response => {})
  .catch(error => {
    console.error(`An error occurred: ${error}`); //An error occurred: AxiosError: Request failed with status code 404
  });

throw 'done'; //throw error to kill the earlier server, otherwise this example will stay running until we ctrl-c out of it 

stonks