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

v1.0.1

Published

Proxy wrapper that ensures connectivity and supports fetch and axios

Downloads

39

Readme

proxy-connector

Proxy wrapper that ensures connectivity and supports fetch and axios

npm i proxy-connector

Usage

const ProxyConnector = require('proxy-connector')

const proxy = new ProxyConnector({
  protocol: 'http',
  host: 'example.com',
  port: 3128,
  username: 'example',
  password: 'secret123',
  session: Math.random().toString()
})

await proxy.check()

console.log(proxy.address)

Axios:

const res = await axios.get('https://checkip.amazonaws.com', { proxy: proxy.toObject() })

console.log(res.data)

Fetch:

const { HttpsProxyAgent } = require('https-proxy-agent')

const agent = new HttpsProxyAgent(proxy.toUpstream())
const res = await fetch('https://checkip.amazonaws.com', { agent })

console.log(await res.text())

API

proxy = new ProxyConnector(options)

Create a new instance.

Options:

{
  protocol, // Defaults to process.env.PROXY_PROTOCOL or 'http'
  host, // Defaults to process.env.PROXY_HOST
  port, // Defaults to process.env.PROXY_PORT
  username, // Defaults to process.env.PROXY_USERNAME
  password, // Defaults to process.env.PROXY_PASSWORD
  country, // E.g. 'ar' (depends on your provider)
  city,
  session, // Defaults to a random fixed session
  streaming: false
}

proxy.url

Returns a constructed URL based on the protocol, host, and port.

proxy.password

Returns a constructed password based on the country, city, and session.

upstream = proxy.toUpstream()

Returns the full proxy URL with username and password included.

Example: http://user:[email protected]:3128

upstream = proxy.toObject()

Returns the proxy settings with username and password included.

Example: { protocol, host, port, auth: { username, password } }.

proxy.randomize()

Changes the session to a new random one.

await proxy.check()

Ensures that the proxy works. It can be called multiple times.

It also saves the proxy IP in proxy.address.

It uses connectivity-check internally.

License

MIT