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

@biorate/proxy

v2.1.5

Published

Proxy connector

Readme

@biorate/proxy

TCP proxy connector — lightweight, configurable TCP load balancer with liveness checks and connection failover.

Features

  • TCP proxy — listens on a local port, forwards connections to a selected upstream.
  • Client failover — automatically selects healthy upstreams based on HTTP liveness probes (Patroni-compatible).
  • Health checks — periodic liveness polling; switches upstream on failure.
  • Unix socket support — listen on Unix domain sockets.
  • Stats page — optional HTTP server with Pug-rendered connection statistics.
  • @kill() destructor — graceful cleanup on shutdown.

Installation

pnpm add @biorate/proxy

Requires @biorate/connector, @biorate/inversion, @biorate/config, @biorate/tools, @biorate/axios, pug.

Quick start

import { Server as HTTPServer } from 'http';
import { Server as TCPServer } from 'net';
import { inject, container, Types, Core } from '@biorate/inversion';
import { IConfig, Config } from '@biorate/config';
import { ProxyConnector } from '@biorate/proxy';

const httpPort = 8001;
const clientPort = 7001;
const serverPort = 7002;

class Root extends Core() {
  @inject(ProxyConnector) public connector: ProxyConnector;
  public http: HTTPServer;
  public tcp: TCPServer;

  protected constructor() {
    super();
    this.http = new HTTPServer();
    this.http.listen(httpPort);
    this.http.on('request', (req, res) => { res.writeHead(200); res.end('1'); });
    this.tcp = new TCPServer();
    this.tcp.listen(clientPort);
    this.tcp.on('connection', (socket) =>
      socket.on('data', (data) => socket.write(`${data} world!`)),
    );
  }
}

container.bind<IConfig>(Types.Config).to(Config).inSingletonScope();
container.bind<ProxyConnector>(ProxyConnector).toSelf().inSingletonScope();
container.bind<Root>(Root).toSelf().inSingletonScope();

container.get<IConfig>(Types.Config).merge({
  Proxy: [{
    name: 'connection',
    retry: 10,
    server: { address: { host: 'localhost', port: serverPort } },
    clients: [{
      liveness: `http://localhost:${httpPort}`,
      address: { host: 'localhost', port: clientPort },
    }],
  }],
});

(async () => {
  const root = container.get<Root>(Root);
  await root.$run();
  const { Socket } = await import('net');
  const socket = new Socket();
  socket.connect(serverPort);
  socket.write('Hello');
  socket.on('data', (data) => console.log(data.toString())); // 'Hello world!'
})();

API Reference

ProxyConnector

| Member | Type | Description | |---------------------|-------------------------------------------|-----------------------------------------------| | namespace | 'Proxy' | Config key for connection definitions. | | connect(config) | (config) => Promise<IProxyConnection> | Creates ProxyConnection with client selection. | | stats() | () => void | Starts optional HTTP stats server. | | getStatData() | () => object[] | Returns active connection stats for rendering. |

Config

interface IProxyConfig extends IConnectorConfig {
  retry?: number;            // max retries for client selection (default 10)
  timeout?: number;          // ms between selection attempts (default 1000)
  checkInterval?: number;    // ms between health checks (< 0 = disabled)
  server: {
    options?: ServerOpts;
    address: ListenOptions;  // { host, port } or { path: '/tmp/sock' }
  };
  clients: IClientOption[];  // upstream backends
}

interface IClientOption {
  liveness?: string;         // HTTP URL for health check
  address: TcpSocketConnectOpts;
  options?: SocketConstructorOpts;
}

Additional ProxyStats config:

ProxyStats: {
  enabled?: boolean;      // default false
  port: number;
  host?: string;          // default 'localhost'
}

Errors

| Error | Condition | |--------------------------------|--------------------------------------------------| | ProxyCantConnectError | Proxy connection creation fails. | | ProxyConnectionTimeoutError | No healthy upstream selected within retry limit. |

Architecture

ProxyConnector extends Connector<IProxyConfig, IProxyConnection>
│
├── namespace = 'Proxy'
├── connect(config)
│   └── ProxyConnection.create(config)
│       ├── select() → iterate clients, ping liveness, pick first healthy
│       ├── listen() → create TCP server, pipe sockets
│       └── check() → periodic health re-evaluation
│
├── @init() initialize()
│   ├── super.initialize() — create connections
│   └── stats() — optional HTTP stats server
│
└── ProxyConnection
    ├── server: Server (TCP listener)
    ├── client: IClientOption (selected upstream)
    ├── select() — liveness-based failover
    ├── listen() — accept connections, proxy TCP
    ├── check() — background health polling
    ├── isActive(client) — check if client is current
    └── stat — { read, write } byte counters

Learn

  • Documentation can be found here - docs.

Release History

See the CHANGELOG

License

MIT