1.1.4 • Published 2 years ago
ngrok-v3 v1.1.4
NOTE
ngrok-v3 is deprecated due to this package being renamed to rokng. Please use rokng instead. This package will not be updated in the future.
ROKNG
This package is the unofficial wraper of ngrok in a simple to use API.
Install
npm install rokng
Usage
import { Ngrok } from 'rokng';
async function main() {
// check if ngrok is installed
const installed = Ngrok.isInstalled;
// if ngrok isn't installed, install it
if (!installed) {
Ngrok.install();
}
// start a TCP tunnel to port 8080
const tunnel = await Ngrok.startTCPTunnel(8080);
// get tunnel data
const tunnelData = tunnel.getData();
// get tunnel host and port
const { host, port } = tunnelData;
console.log(`Tunnel is up at ${host}:${port}`);
// stop the tunnel
tunnel.kill();
// start an HTTPS tunnel to port 443
const tunnel2 = await Ngrok.startHTTPSTunnel(443);
// get tunnel data
const tunnel2Data = await tunnel2.getData();
// get tunnel host and port
const { host: host2, port: port2 } = tunnel2Data;
console.log(`Tunnel 2 is up at ${host2}:${port2}`);
// stop the tunnel
tunnel.kill();
}
main();