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

proxy

v2.2.0

Published

An HTTP proxy written with Node.js (think Squid)

Downloads

240,167

Readme

proxy

An HTTP proxy written with Node.js (think Squid)

This module provides standard "HTTP proxy" logic. You can script your own server using the proxy server API. Be sure to take a look at the "Examples" section below.

There is also a companion proxy(1) CLI tool, which spawns an HTTP(s) proxy server with the specified options.

You could think of proxy(1) as similar to some of the other popular open source HTTP proxy software:

Examples

Basic HTTP(s) proxy server

A basic HTTP(s) server with all the default options. All requests are allowed. CONNECT HTTP method works as well.

import * as http from 'http';
import { createProxy } from 'proxy';

const server = createProxy(http.createServer());
server.listen(3128, () => {
  var port = server.address().port;
  console.log('HTTP(s) proxy server listening on port %d', port);
});

CLI Tool Examples

The proxy(1) CLI tool can be used to spawn HTTP(s) proxy server instances with various options.

Port to bind to

Pass the -p/--port option to with a port number to specify a TCP port to bind to. Defaults to 3128 if none is specified.

$ proxy --port 8080

Custom Proxy-Authenticate command

Pass the -a/--authenticate switch with a command to execute when the client Proxy-Authorization header is given. This command determines whether or not the request is authorized based on the "exit code" of the command.

The relevant request authentication information is passed in as PROXY_AUTH_USERNAME, PROXY_AUTH_PASSWORD and PROXY_AUTH_SCHEME environment variables.

For example, to authorize "Basic" authentication with username "foo" and password "bar":

$ proxy --authenticate 'if \
    [ "$PROXY_AUTH_USERNAME" = "foo" ] && \
    [ "$PROXY_AUTH_PASSWORD" = "bar" ]; \
      then exit 0; \
    fi; \
    exit 1;'

Custom outgoing interface

Pass the -l/--local-address argument with an IP address of the network interface to send the outgoing requests through. It is the equivalent of setting a localAddress field in the options when calling http.request().

$ proxy --local-address 192.168.0.10