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

dprox

v1.6.1

Published

declarative reverse proxy for local development

Downloads

148

Readme

dprox – declarative reverse proxy for local development

Greenkeeper badge

a simple wrapper around express-http-proxy

Getting Started

ensure Node is available, then install dprox:

$ npm install dprox

create a proxy.config.js:

module.exports = {
    self: "localhost:8080",
    "/foo": {
        uri: "localhost:8081",
        preserveHost: true,
        preservePrefix: true
    },
    "/bar": {
        uri: "localhost:8082",
        preserveHost: true
    },
    "/assets": "localhost:3000"
};

dprox starts the proxy, reading configuration from proxy.config.js within the current working directory

dprox -c /path/to/any.js reads a custom configuration file instead

(note that this assumes the dprox executable resides on your PATH, otherwise you might have to provide the full path to that file)

Configuration

proxy.config.js is expected to export an object mapping paths to applications

an optional self entry defines the proxy's own address (which defaults to "localhost:3333") - this is either a string or a { uri, limit } object (limit sets the request body size limit - see express-http-proxy documentation for details)

each entry is either a URI string, an Express middleware function (see below) or an object with the following options:

  • uri is the address to pass requests to
  • preserveHost: true passes the HTTP Host header through to the respective application
  • preservePrefix: true passes the entry's path (URI prefix) through to the respective application
  • insecure: true skips verification of SSL/TLS certificates
  • requestHeaders: an object of custom headers to add to any incoming request (e.g. { "X-TOKEN": "abc123" }) - these are added to and take precedence over any existing request headers
  • responseHeaders: an object of custom headers to add to any outgoing response (e.g. { "Cache-Control": "max-age=1" }) - these are added to and take precedence over any existing response headers
  • log, if truthy, activates logging for this entry
    • if the value is a function, it will be invoked with the respective HTTP request object (e.g. log: req => { console.log(req.method + req.url); })
    • otherwise the value, unless true, will be prepended to the default log message (e.g. log: "[PROXY]")

middleware functions to serve static files from a corresponding directory or to mock a JSON response might look like this:

    "/assets": require("express").static("static"),
    "/data": (req, res, next) => {
        let data = {
            foo: "hello",
            bar: "world"
        };
        return res.json(data);
    }

Contributing

  • npm install downloads dependencies
  • npm test checks code for stylistic consistency