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-agent

v6.4.0

Published

Maps proxy protocols to `http.Agent` implementations

Downloads

33,461,257

Readme

proxy-agent

Maps proxy protocols to http.Agent implementations

This module provides an http.Agent implementation which automatically uses proxy servers based off of the various proxy-related environment variables (HTTP_PROXY, HTTPS_PROXY and NO_PROXY among others).

Which proxy is used for each HTTP request is determined by the proxy-from-env module, so check its documentation for instructions on configuring your environment variables.

An LRU cache is used so that http.Agent instances are transparently re-used for subsequent HTTP requests to the same proxy server.

The currently implemented protocol mappings are listed in the table below:

| Protocol | Proxy Agent for http requests | Proxy Agent for https requests | Example |:----------:|:-------------------------------:|:--------------------------------:|:--------: | http | http-proxy-agent | https-proxy-agent | http://proxy-server-over-tcp.com:3128 | https | http-proxy-agent | https-proxy-agent | https://proxy-server-over-tls.com:3129 | socks(v5)| socks-proxy-agent | socks-proxy-agent | socks://username:[email protected]:9050 (username & password are optional) | socks5 | socks-proxy-agent | socks-proxy-agent | socks5://username:[email protected]:9050 (username & password are optional) | socks4 | socks-proxy-agent | socks-proxy-agent | socks4://some-socks-proxy.com:9050 | pac-* | pac-proxy-agent | pac-proxy-agent | pac+http://www.example.com/proxy.pac

Example

import * as https from 'https';
import { ProxyAgent } from 'proxy-agent';

// The correct proxy `Agent` implementation to use will be determined
// via the `http_proxy` / `https_proxy` / `no_proxy` / etc. env vars
const agent = new ProxyAgent();

// The rest works just like any other normal HTTP request
https.get('https://jsonip.com', { agent }, (res) => {
  console.log(res.statusCode, res.headers);
  res.pipe(process.stdout);
});

API

new ProxyAgent(options?: ProxyAgentOptions)

Creates an http.Agent instance which relies on the various proxy-related environment variables. An LRU cache is used, so the same http.Agent instance will be returned if identical args are passed in.