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

caronte-proxy

v3.1.4

Published

An HTTP(S) Proxy, suitable to test proxying during development

Downloads

48

Readme

Caronte Proxy (caronte-proxy)

npm version Build Status FOSSA Status

What's this for?

Caronte is my answer to the need of hosting a feature-rich-enough HTTP Proxy in NodeJS.

I have tons of NodeJS code that has to deal with Proxies, and such code needs testing. I started digging, and I found many libraries to build proxies (like the famous http-proxy), but no "out of the box" solutions that fit my needs.

So I made one.

This is in no way something you want to use in production: this Proxy is built for testing and I haven't spent a second checking memory consumption nor performance. This Proxy is to provide you with a testing ground: so my focus is on adding typical commercial Proxy features, rather then being production-ready.

Some features include:

  • Support for HTTP and HTTPS proxying
  • Support for HTTPS (it uses a self-signed certificate by default, but you can provide one)
  • Support for Proxy Basic HTTP Authentication

Eventually I'd like to add SOCKS support but it's not an urgent need of mine, so it can wait. Maybe you will build that!

Setup

var options = {};
var caronteProxy = require('caronte-proxy')(options, function (req, res, err) {
  if (!err) {
    console.log('A soul has approached Caronte with a coin for its journey...');
  } else {
    console.error('A soul has approached Caronte without a coin, so it\'s going to remain in Limbo for ethernity...');
  }
});

caronteProxy.on('listening', function () {
  console.log('Caronte is ready to carry new souls across the Acheronte...');
});

caronteProxy.listen(6666);

And here is how the default options look like:

const defaultProxyOptions = {
  key: fs.readFileSync(__dirname + '/lib/proxy.selfsigned.key'),    //< TLS key to be used for HTTPS proxying (default: built-in self signed key)
  cert: fs.readFileSync(__dirname + '/lib/proxy.selfsigned.cert'),  //< TLS certificate to be used for HTTPS proxying (default: built-in self signed certificate)
  httpAgent: false,       //< http.Agent to use for HTTP traffic (default: 'false', i.e. no Agent, no socket reuse)
  httpsAgent: false,      //< https.Agent to use for HTTPS traffic (default: 'false', i.e. no Agent, no socket reuse)
  auth: false             //< Example value: { username: USERNAME, password: PASSWORD[, realm: USED_ONLY_IF_NOT_EMPTY]}
};

Any of those properties can be overridden.

Agents and testing in NodeJS itself

If you are testing code that involves setting/manipulating the NodeJS Agents and Global Agents, it's important that the options httpAgent and httpsAgent are left to false: this will ensure that the communication though the proxy will not directed to the Node default Global Agents, making your code very hard to test.

In other words, avoid Agent inception.

Debugging

Caronte uses the NPM module debug, so debugging is trivial: just set the ENV variable DEBUG to caronte:*.

Something like:

DEBUG=caronte:* npm test

Check out debug for more fine tuning.

"Caronte"?

In Greek mythology, Charon or Kharon (/ˈkɛərɒn/ or /ˈkɛərən/; Greek Χάρων; Italian Caronte) is the ferryman of Hades who carries souls of the newly deceased across the rivers Styx and Acheron that divided the world of the living from the world of the dead.

Credit for this awesome name goes to Antonio Pironti, friend and currently colleague.

Disclaimer

This project is heavily inspired by cloudberry, but I forked away because I needed it to:

  • Run on more than just latest NodeJS
  • Avoid using the Global Agent, and instead create for every request a fresh connection
  • Support for HTTP Basic Authentication
  • Ability to override the HTTP(s) Agent used by the Proxy
  • Debug-ability

If you are after a Proxy written with latest NodeJS bells and wissle, you should check cloudberry out.

License

Apache 2.0 (txt)

FOSSA Status