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

bouncy

v3.2.2

Published

route incoming http requests to http servers

Downloads

1,325

Readme

bouncy

pipe raw http traffic from incoming http requests to remote endpoints

build status

trampoline

example

route.js

Route requests based on the host field to servers on ports 8001 and 8002:

var bouncy = require('bouncy');

var server = bouncy(function (req, res, bounce) {
    if (req.headers.host === 'beep.example.com') {
        bounce(8001);
    }
    else if (req.headers.host === 'boop.example.com') {
        bounce(8002);
    }
    else {
        res.statusCode = 404;
        res.end('no such host');
    }
});
server.listen(8000);

var server = bouncy(opts={}, cb)

bouncy(cb) returns a new net.Server object that you can .listen() on.

If you specify opts.key and opts.cert, the connection will be set to secure mode using tls. Do this if you want to make an https router.

If the arity of cb is 3, you'll get the response object res in cb(req, res, bounce). Otherwise you just get cb(req, bounce).

If you are using more than one SSL cert, add opts.SNICallback. See the example http-https-sni.js and the nodejs tls page for details.

bounce(stream, opts={})

Call this function when you're ready to bounce the request to a stream.

The exact request that was received will be written to stream and future incoming data will be piped to and from it.

To send data to a different url path on the destination stream, you can specify opts.path.

To change the http verb you can set opts.method.

You can specify header fields to insert into the request with opts.headers.

bounce() returns the stream object that it uses to connect to the remote host.

bounce(port, ...), bounce(host, port, ...), bounce(url)

These variants of bounce() are sugar for bounce(net.connect(port)) and bounce(net.connect(port, host)).

Optionally you can pass port and host keys to opts and it does the same thing.

Passing bounce() a string that looks like a url (with or without "http://") will set the opts.host, opts.port, and opts.path accordingly.

usage

usage: bouncy FILE PORT

Create a routes FILE like this:

  {
    "beep.example.com" : 8000,
    "boop.example.com" : 8001
  }

Then point the `bouncy` command at this `routes.json` file and give it
a port to listen on: 

  bouncy routes.json 80

The `routes.json` file should just map host names to host/port combos. Use a
colon-separated string to specify a host and port in a route.

Use `""` for the host as a default route.

You can optionally specify a listen address as the third parameter or with
`--address`. It defaults to `0.0.0.0`. Specify `::` to listen on both IPv4 and
IPv6 addresses.

install

With npm, to get the library do:

npm install bouncy

or to install the command-line tool do:

npm install -g bouncy

license

MIT