Toll
Utility to manage dynamic micro-services by proxying hostnames to other node servers.
Why
- Sometimes you are stuck in an environment without something like NGINX.
- Services may be too sporadic to properly configure.
- You like node js.
Installation
Npm
npm install toll
Registering a Toll service.
var toll = ; // Start up a server at an arbitrary port.var server = ; // Connect to Toll proxy.var proxy = toll; // Register the server with toll.proxy;
Starting a Toll server.
var toll = ;var server = toll; // This server will automatically listen for new Toll registrations and proxy by hostname.server;
API
- toll.createProxy() : Creates a Toll proxy server.
// Creates a net.Server which which will automatically proxy registered toll services.var proxy = toll;
- toll.connect(path)
- toll.connect(port, host)
- toll.connect({ path, host, port, heartbeat }) Creates a new connection to a Toll proxy at a given port.
// Creates a proxy Connection that sends a heartbeat every 15 seconds.// Api is the same as net.connect. (except for the return value).var proxy = toll;
The Following api works the same for both the proxy server and the connected hosts.
- proxy.register(hosts, path)
- proxy.register(hosts, port, host)
- proxy.register(hosts, { path, host, port }) -> Promise Registers hosts with a Toll proxy.
// Registers arguments are flexable like `toll.connect` but must start with a host(s).proxy;proxy;
- proxy.remove(hosts) -> Promise Unregisters a hosts with a Toll proxy.
proxy;proxy;
CLI
Start a Toll Proxy server from the cli.
npm install toll -g toll <port> [ip]toll 80 127.0.0.1
Contributions
- Use
npm test
to run tests.
Please feel free to create a PR!