How to use the ngrok.connect function in ngrok

To help you get started, we’ve selected a few ngrok examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github safaricom / mpesa-node-library / tests / helpers / ngrok.js View on Github external
function ngrokify (server) {
  if (typeof server === 'function') server = http.createServer(server)

  // let ngroked = Object.create(server)
  let ngrokURL

  server.once('close', function () {
    console.log('Closing time :)')
    ngrokURL && ngrok.disconnect(ngrokURL)
  })

  let addr = server.address()
  if (!addr) server.listen(0)
  addr = server.address()
  console.log('Using Port ' + addr.port)
  return ngrok.connect(addr.port).then(function (url) {
    ngrokURL = url
    return url
  })
}
module.exports = ngrokify
github Yoctol / bottender / packages / bottender / src / cli / providers / sh / dev.ts View on Github external
cp.kill('SIGTERM');

    cp = createProcess();
  });

  const useTypeScript = false; // FIXME

  if (useTypeScript) {
    // watch js and run cp
    // watch ts and compile to dist
  } else {
    // watch all and run cp
  }

  if (!isConsole) {
    const url = await ngrok.connect(port);

    Object.entries(channels || {})
      .filter(([, { enabled }]) => enabled)
      .forEach(([channel, { path: webhookPath }]) => {
        const routePath = webhookPath || `/webhooks/${channel}`;

        console.log(`${channel} webhook url: ${url}${routePath}`);
      });
  }
};
github Automattic / browser-repl / repl.js View on Github external
srv.listen(function(){
    ngrok(srv.address().port, function(err, url){
      if (err) {
        console.error('… error setting up reverse tunnel');
        console.error(err.stack);
        return;
      }

      console.log('… booting up \u001b[96m'
        + browser + '\u001b[39m (' + (version || 'latest')
        + ') on ' + platform);
      spawn(url);
    });
    // let `error` throw
  });
}
github adobe / wskdebug / src / debugger.js View on Github external
console.log("Setting up ngrok", this.argv.ngrokRegion ? `(region: ${this.argv.ngrokRegion})` : "");
            }

            // 1. start local server on random port
            this.ngrokServer = http.createServer(this.ngrokHandler.bind(this));
            // turn server.listen() into promise so we can await
            const listen = util.promisify( this.ngrokServer.listen.bind(this.ngrokServer) );
            await listen(0, '127.0.0.1');

            // 2. start ngrok tunnel connected to that port
            this.ngrokServerPort = this.ngrokServer.address().port;

            // create a unique authorization token that we check on our local instance later
            // this adds extra protection on top of the uniquely generated ngrok subdomain (e.g. a01ae275.ngrok.io)
            this.ngrokAuth = crypto.randomBytes(32).toString("hex");
            const ngrokUrl = await ngrok.connect({
                addr: this.ngrokServerPort,
                region: this.argv.ngrokRegion
            });

            // 3. pass on public ngrok url to agent
            action.parameters.push({
                key: "$ngrokUrl",
                value: url.parse(ngrokUrl).host
            });
            action.parameters.push({
                key: "$ngrokAuth",
                value: this.ngrokAuth
            });

            console.log(`Ngrok forwarding: ${ngrokUrl} => http://localhost:${this.ngrokServerPort} (auth: ${this.ngrokAuth})`);
github uport-project / uport-credentials / examples / requestcredential.js View on Github external
const server = app.listen(8088, () => {
  ngrok.connect(8088).then(ngrokUrl => {
    endpoint = ngrokUrl
    console.log(`Requestor Service running, open at ${endpoint}`)
  })
})
github twilio / twilio-chat-js-cordova-example / app.js View on Github external
app.listen(3002, function() {
  console.log('Token provider listening on port 3002!');

  var ngrokOptions = {
    proto: 'http',
    addr: 3002
  };
  if (config.ngrokSubdomain) {
    ngrokOptions.subdomain = config.ngrokSubdomain
  }

  ngrok.connect(ngrokOptions).then(function(url) {
    console.log('ngrok url is ' + url);
  });
});
github jonyablonski / bolt / gulpfile.js View on Github external
gulp.task('ngrok-url', function(cb) {
	return ngrok.connect(3000, function(err, url) {
		site = url;
		console.log('serving your tunnel from: ' + site);
		cb();
	});
});
github nuxt-community / modules / packages / ngrok / index.js View on Github external
this.nuxt.hook('build:done', async () => {
    if (!connectedUrl) {
      try {
        const url = await ngrok.connect(opts)
        connectedUrl = url
        return console.log(chalk.bgGreen.black(' OPEN ') + chalk.green(` ${connectedUrl} for external access`))
      } catch (err) {
        return console.error('[nuxt][ngrok] ' + chalk.red(err.details.err))
      }
    }
    connectedUrl &&
      console.log(chalk.bgGreen.black(' OPEN ') + chalk.green(` ${connectedUrl} for external access`))
  })
github mcasimir / mobile-angular-ui / gulpfile.js View on Github external
var ngRockTunnel = function(cb){
  ngrok.connect({ port: 3001 }, cb);
};
github pemrouz / popper / index.js View on Github external
server.listen(config.port, function(){
      log('running on port', server.address().port)
      !config.notunnel && require('ngrok').connect(server.address().port, function(e, url){
        log('tunnelling', url && url.magenta)
        return e ? err('error setting up reverse tunnel', e.stack)
                 : (config.browsers || [])
                    .map(canonical)
                    .filter(Boolean)
                    .forEach(boot(url))
      })
    })
  }

ngrok

node wrapper for ngrok

BSD-2-Clause
Latest version published 2 years ago

Package Health Score

62 / 100
Full package analysis