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 🙏

© 2024 – Pkg Stats / Ryan Hefner

chaussette

v0.2.5

Published

A nodejs proxy to connect to TCP servers using browser's WebSocket API.

Downloads

8

Readme

Chaussette 🧦

GitHub npm

Chaussette is a NodeJS proxy. It allows you to communicate with a TCP server (or any protocol built on it) from a browser's WebSocket.

When started on port 9898, for example, Chaussette will spawn a WebSocket server and, for every WebSocket client connecting to it, will create an associated Socket connected to specified host and port, and forward every data to it.


Usage

Chaussette is usable either from command-line interface, or as a node module:

Either way, you can install from yarn / npm:

npm install chaussette

If you wish to use it from CLI, you can install it globally:

npm install chaussette -g

CLI usage

chaussette -l 9898 -t example.com -p 9999 -v 2

Using the previous command line, WebSockets will be able to connect to localhost on port 9898. Everything data sent by client over such WebSocket will be then forwarded to example.com, on port 9999.

Options used here are the following:

  • -l (--listenport) port to listen on
  • -t (--target) target to forward data to
  • -p (--targetport) port to forward data to
  • -v (--verbosity) verbosity level:
    • 0: error logs only
    • 1: previous + default and warning logs
    • 2: previous + debug logs

Node module usage

const Chaussette = require('chaussette');

const proxy = new Chaussette({
  listenPort: 9898,
  targetAddr: 'example.com',
  targetPort: 9999,
  verbosity: 1, // optional, default is 0
  logging: {
    // optional, logging options
    format: 'HH-mm-ss', // logs timestamp formatting, default is 'DD-MM-YY HH:mm:ss'
  },
});

// configures the server and starts listening on port 9898
proxy.start();

// preventing forwarding WS client's messages that start with "DO NOT FORWARD:"
proxy.onwsmessage = (message, pairId) => {
  if (message.startsWith('DO NOT FORWARD:'))
    proxy.preventNextWSMessageForward(pairId);
};

// preventing forwarding TCP server's messages that do not start with "FORWARD IT:"
proxy.ontcpmessage = (message, pairId) => {
  if (!message.startsWith('FORWARD IT:'))
    proxy.preventNextTCPMessageForward(pairId);
};

Left to do

Features

  • [x] Usage from CLI
  • [x] Usage from NodeJS
  • [x] External messages hooks (ex. 'onmessage' from Chaussette object)
  • [ ] Allow WS to provide the host and port to connect to (with default callback)

Logs

  • [x] Verbosity levels
  • [x] Colored logs
  • [x] Allow logs options
  • [x] Allow date formatting in logs (dayjs / momentjs ?)
  • [ ] Log connected client's informations + on message

Others

  • [ ] Send proper closing informations to both ends