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

web-proxy

v1.1.2

Published

Web Proxy (forward proxy) for intercepting and selectively caching HTTP requests.

Downloads

24

Readme

Web Proxy

Travis build status NPM version

Web Proxy (forward proxy) for intercepting and selectively caching HTTP requests.

Use Case

web-proxy has been designed to selectively cache outgoing HTTP requests for logging and re-iteration purposes, e.g. if you are running an inefficient web scrapping service or wish to re-run scrapping service using earlier fetched pages.

Demo

cURL, web proxy, mitmproxy

Illustration demonstrates cURL requests being made using web-proxy.

web-proxy is configured to:

  • cache all HTTP GET requests that result in 200 response.
  • to forward all resulting HTTP requests to further proxy (mitmproxy).

Command Line Usage

node ./bin/proxy --help

MySQL

Web Proxy can be used with a persistent data store. The only backend supported at the moment is MySQL.

To enable use of the MySQL backend, provide connections credentials at the time of starting the proxy.

Database schema can be obtained from ./database/proxy.sql. Note that table is using ROW_FORMAT=COMPRESSED. In order to benefit from the compression, ensure that the following MySQL variables are set:

innodb_file_format=BARRACUDA
innodb_file_per_table=ON

For more information, refer to http://stackoverflow.com/a/13636565/368691.

Proxy

Web Proxy can forward all outgoing HTTP requests to another proxy.

To enable forwarding, provide proxy credentials at the time of starting the proxy.

node ./bin/proxy --help

API

WebProxy can be used programmatically.

var WebProxy = require('../src/webproxy'),
    config = {},
    server;

/**
 * @param {Object} reference
 * @param {String} reference.method
 * @param {String} reference.url
 * @return {Null} Returning null will allow HTTP request to progress.
 * @return {Object} response
 * @return {Number} response.statusCode
 * @return {Object} response.headers
 * @return {String} response.body
 */
config.read = function (request) {
    //
};

/**
 * @param {Object} reference
 * @param {String} reference.method
 * @param {String} reference.url
 * @param {Object} response
 * @param {Number} response.statusCode
 * @param {Object} response.headers
 * @param {String} response.body
 */
config.write = function (request, response) {
    //
};

/**
 * @param {Object} config
 * @param {Function} config.read
 * @param {Function} config.write
 * @param {Object} config.logger
 */
server = WebProxy(config);

server.listen(9000);

Data Store

Data can be read/written using custom logic.

There are two existing data store interfaces:

| Name | Description | | --- | --- | | DataStore.session | Session persits data in an object for the duration of the script runtime. | | DataStore.database | Data is read/written to/from a MySQL database. |

Refer to the ./bin/proxy.js implementation to see a working example.