rokng
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

ROKNG

This package is the unofficial wraper of ngrok in a simple to use API.

Install

npm install rokng

Usage

// esm
import { Ngrok } from 'rokng';
// cjs
const Ngrok = require('rokng').default;

async function main() {
    // check if ngrok is installed
    const installed = Ngrok.isInstalled;

    // if ngrok isn't installed, install it
    if (!installed) {
        await 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();

Dependencies (6)

Dev Dependencies (1)

Package Sidebar

Install

npm i rokng

Weekly Downloads

0

Version

1.2.0

License

ISC

Unpacked Size

52.5 kB

Total Files

11

Last publish

Collaborators

  • 1nch