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

thundermole

v1.6.6

Published

Proxy or redirect requests to different applications based on an API response

Downloads

32

Readme

Thundermole

Proxy or redirect requests to different applications based on an API response. Read about how we use it.

NPM version Node.js version support Build status Dependencies GPLv3 licensed

Thundermole Flow Diagram

Table Of Contents

Installing

  • Install Node.js
  • Clone this repo locally and cd into it
  • Copy the sample routes with cp config/routes.sample.json config/routes.json
  • Optionally copy the sample StatsD config with cp config/statsd.sample.json config/statsd.json
  • Optionally copy the sample syslog config with cp config/syslog.sample.json config/syslog.json
  • Run make to install dependencies and run the test suite

Running Thundermole

Usage: bin/thundermole [options]

Options:

  -h, --help                 output usage information
  -V, --version              output the version number
  -c, --config <path>        the directory to look for config files in
  -C, --cluster              create a cluster of workers for handling requests
  -p, --port <port>          the port to run on
  -w, --workers <num>        the number of workers to add to the cluster
  -r, --rewrite-host-header  whether to rewrite the host header
  -P, --ping-url             A ping URL for the application

Configuration

bin/thundermole reads configurations from JSON files.

routes.json

Should contain application routes as outlined in the routes option documentation. See routes.sample.json for an example.

statsd.json

Optional. Should contain statsd configurations as outlined in the statsd option documentation. See statsd.sample.json for an example.

syslog.json

Should contain syslog configurations as outlined in the winston-syslog documentation. See syslog.sample.json for an example.

JavaScript Interface

Thundermole can be loaded as a module and run programatically.

Basic API

var thundermole = require('thundermole');

// Create a thundermole application
var mole = thundermole({
    // ... options ...
});

// Start the thundermole application on port 3000
mole.listen(3000);

Options

routes (object)

Required. A simple routing hash. Each property maps to the first part of a request path, and the value should indicate the API endpoint to use for matching requests. For example:

{
    "foo": "http://my-api/"
}

Routes can also be regular expressions which gives you a little more flexibility. The URL path of the request is tested against, and has the preceeding slash stripped. It's worth noting that backslashes need to be escaped as we're working in JSON:

{
    "/foo\\/bar/i": "http://my-api/"
}

Also regular expression routes do not match from the start and end of the path – you'll need to manually specify that:

{
    "/^foo$/i": "http://my-api/"
}

routes.default (string)

Required. The default route to use if no others match the request.

appendHeader (string)

Optional. The header to send API-appended data in. Defaults to X-Proxy-Appended-Data.

rewriteHostHeader (boolean)

Optional. Whether to rewrite the Host header to match the proxy target. Defaults to true.

statsd (object)

Optional. A node-statsd configuration object, as outlined in their documentation.

logger (object)

Optional. An object with the methods debug, error, info, and warn which will be used to report errors and request information.

pingUrl (string)

Optional. A URL path (including preceding slash) which, when requested, will respond with a 200 status. This can be used for monitoring your Thundermole instance. Defaults to null.

Running Example Applications

Thundermole comes with an example application which runs two APIs and two backends. To run these you'll need to install Foreman, or look into the example Procfile and spin up each process separately.

If you have Foreman, run the example application with:

foreman start -d example

Building Thundermole-Compatible APIs

In order for Thundermole to be able to communicate with your API, you'll need to follow the API Specification.

Contributing

To contribute to Thundermole, clone this repo locally and commit your code on a separate branch.

Please write unit tests for your code, and check that everything works by running the following before opening a pull-request:

make ci

License

Copyright © 2015 Springer Nature.
Thundermole is licensed under the GNU General Public License 3.0.