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 🙏

© 2025 – Pkg Stats / Ryan Hefner

detour-proxy

v0.0.25

Published

Reverse proxy for frontend developers

Readme

Detour

A reverse proxy to untie the knot between frontend and backend developers

Join the chat at https://gitter.im/candrholdings/detour

Problems

Frontend developers cannot focus on their development because

  • Backend deployment is complicated and take up lot of resources on their box
  • New features depends on backend API readiness
    • Mocking is okay but changing spec makes mock update time consuming
  • Need to tackle CORS issue during tight development schedule

Scenarios

  • Decouple frontend and backend development team
    • Join web server and API servers together as if they are from a single server
    • Few frontend developers can use a shared backend server, no need to install database in their own box to run the whole site
    • Don't wait until backend API is ready, mock a response JSON/XML and continue web development
    • Built-in LiveReload server for quick consumption
  • Mock changes on big production site
    • Mock as you need, host a smaller staging site without downloading everything from production
    • Support server side includes
  • Simple URL rewrite

Install

Run npm install detour-proxy -g to install detour in your box. For every site,

  • Create a detour-config.json (sample configuration below)
  • Run detour to start the server
    • For custom config path and port, run detour path-to-config-file.json 1337

Sample configuration

{
    "logLevel": "follow",
    "mappings": [{
        "from": "/",
        "to": "html/",
        "skipOn404": true
    }, {
        "from": "/api/",
        "to": "http://api.example.com/"
    }]
}

logLevel could be error, warning, info, skip, forward, follow. Detour use winston.

mappings defines how request could be remapped. Mappings can be overlapping and they are processed from top to bottom (first win will stop other rules).

In the sample configuration, the first mapping will rewrite / (i.e. all requests to the site) to local directory html/. For example, request to /helloworld.html will be served with local file html/helloworld.html, relative to the config file.

skipOn404 indicate that if the requested file is not found, it will skip this mapping and evaluate the next one. Otherwise, detour will return with 404.

You can specify both file path or http:// path to the to argument.

The second mapping will rewrite /api/ to http://api.example.com/. For example, requests to /api/helloworld will be forwarded on behalf to http://api.example.com/helloworld/. Most request headers will be retained. Some are discarded, e.g. accept-encoding.

Currently, we do not add headers (e.g. x-forwarded-for, x-forwarded-proto) to the forwarded request.

Default port

By default, detour use a random port number 7000-7999. To use a custom port number, you can specify it in the command-line. Type detour path-to-config-file.json 1337 to run detour on port 1337 with configuration file path-to-config-file.json.

Default document

For file-based destination, detour adopted index.html as the name of "default document". If the request does not contain a filename (end with slash) and the mapping destination is local file system, detour will add index.html to the request URL.

Server side includes

Detour follow server side includes (or SSI). The SSI path will also be evaluated against the mappings defined in detour-config.json. To aid development, the SSI-ed output will have extra comment <!-- BEGIN SSI /include/topnav.html --> for easier debugging SSI issues.

LiveReload support

Detour built-in LiveReload server. When detour is up, it will watch all mappings that point to local file system. Changes detected will be broadcasted to LiveReload plugin immediately. Instead of using unreliable fs.watch, we use a more reliable approach by crawling every file stats every 2 seconds. We still use fs.watch for auxiliary purpose.

Changelog

  • 0.0.25 (2016-04-20): Log LiveReload events
  • 0.0.24 (2016-03-30): Use chokidar for file watcher

Issues

If you encounter any issues, please file it on GitHub. To speed up our investigation, please file with a minimal repro steps.

Feature requests

If you want to recommend a feature, please file it on issues or chat with us on Gitter. Please let us know rationale behind your request and we will be more than happy to design and implement the feature for you.