JSPM

  • Created
  • Published
  • Downloads 168091
  • Score
    100M100P100Q201864F
  • License BSD-2-Clause

node wrapper for ngrok

Package Exports

  • ngrok

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ngrok) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ngrok Build Status

alt ngrok.com

Ngrok exposes your localhost to the web. https://ngrok.com/

usage

NPM

It will download the ngrok 2.0 binary for your platform and put it into the bin folder. You can also install ngrok globally and use it directly from bash

$ npm install ngrok -g
$ ngrok http 8080

authtoken

You can create basic http/https/tcp tunnel without any authentication. For custom subdomains and more you should obtain authtoken by signing up at ngrok.com

You can pass authtoken as option with each connect or set it once for further tunnels

ngrok.authtoken(token, function(err, token) {});

Or you can set it directly with ngrok

./ngrok authtoken <token>

connect

var ngrok = require('ngrok');

ngrok.connect(function (err, url) {}); // https://757c1652.ngrok.io -> http://localhost:80
ngrok.connect(9090, function (err, url) {}); // https://757c1652.ngrok.io -> http://localhost:9090
ngrok.connect({proto: 'tcp', addr: 22}, function (err, url) {}); // tcp://0.tcp.ngrok.io:48590
ngrok.connect(opts, function(err, url) {});

First connect spawns the ngrok process so each next tunnel is created much faster.

options

ngrok.connect({
    proto: 'http', // http|tcp|tls
    addr: 8080, // port or network address
    auth: 'user:pwd', // http basic authentication for tunnel
    subdomain: 'alex', // reserved tunnel name https://alex.ngrok.io,
    authtoken: '12345' // your authtoken from ngrok.com
}, function (err, url) {});

Other options: name, inspect, host_header, bind_tls, hostname, crt, key, client_cas, remote_addr - read here

disconnect

The ngrok and all tunnels will be killed when node process is done. To stop the tunnels use

ngrok.disconnect(url); // stops one
ngrok.disconnect(); // stops all
ngrok.kill(); // kills ngrok process

emitter

Also you can use ngrok as an event emitter, it fires "connect", "disconnect" and "error" events

ngrok.once('connect', function (url) {};
ngrok.connect(port);

configs

You can use ngrok's configurations files, then just pass name option when making a tunnel

OS X	/Users/example/.ngrok2/ngrok.yml
Linux	/home/example/.ngrok2/ngrok.yml
Windows	C:\Users\example\.ngrok2\ngrok.yml

inspector

When tunnel is established you can use the ngrok interface http://127.0.0.1:4040 to inspect the webhooks done via ngrok.