How to use the ngrok.promise 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 expo / xde / build / application / PackagerController.js View on Github external
value: _asyncToGenerator(function* () {
      var _this = this;

      if (this._ngrokUrl) {
        console.log("Waiting for ngrok to disconnect...");
        yield this._stopNgrokAsync();
        console.log("Disconnected ngrok; restarting...");
      }

      this.ngrokReady$ = new _Promise(function (fulfill, reject) {
        _this._ngrokReadyFulfill = fulfill;
        _this._ngrokReadyReject = reject;
      });

      this.emit('ngrok-will-start', this.opts.port);
      this.ngrokReady$ = ngrok.promise.connect(this.opts.port);
      // this._setCombinedPromises();
      this._ngrokUrl = yield this.ngrokReady$;
      this.emit('ngrok-did-start', this.opts.port, this._ngrokUrl);
      this.emit('ngrok-ready', this.opts.port, this._ngrokUrl);

      console.log("Connected ngrok to port " + this.opts.port + " via " + this._ngrokUrl);
      return this._ngrokUrl;
    })
  }, {
github expo / xde / src / application / PackagerController.js View on Github external
async _stopNgrokAsync() {

    if (this._ngrokUrl) {
      this.emit('ngrok-will-disconnect', this._ngrokUrl);
      try {
        await ngrok.promise.disconnect(this._ngrokUrl);
        let oldNgrokUrl = this._ngrokUrl;
        this._ngrokUrl = null;
        // this._ngrokDisconnectedFulfill(oldNgrokUrl);
        // console.log("Disconnected ngrok");
        this.emit('ngrok-disconnected', oldNgrokUrl);
      } catch (e) {
        console.error("Problem disconnecting ngrok:", e);
        // this._ngrokDisconnectedReject(e);
        this.emit('ngrok-disconnect-err', e);
      }
    }

  }
github expo / xde / build / application / PackagerController.js View on Github external
value: _asyncToGenerator(function* () {

      if (this._ngrokUrl) {
        this.emit('ngrok-will-disconnect', this._ngrokUrl);
        try {
          yield ngrok.promise.disconnect(this._ngrokUrl);
          var oldNgrokUrl = this._ngrokUrl;
          this._ngrokUrl = null;
          // this._ngrokDisconnectedFulfill(oldNgrokUrl);
          // console.log("Disconnected ngrok");
          this.emit('ngrok-disconnected', oldNgrokUrl);
        } catch (e) {
          console.error("Problem disconnecting ngrok:", e);
          // this._ngrokDisconnectedReject(e);
          this.emit('ngrok-disconnect-err', e);
        }
      }
    })
  }, {
github expo / xdl / src / PackagerController.js View on Github external
let oldNgrokUrl = this._ngrokUrl;
        this._ngrokUrl = null;
        // this._ngrokDisconnectedFulfill(oldNgrokUrl);
        // console.log("Disconnected ngrok");
        this.emit('ngrok-disconnected', oldNgrokUrl);
      } catch (e) {
        console.error("Problem disconnecting ngrok:", e);
        // this._ngrokDisconnectedReject(e);
        this.emit('ngrok-disconnect-err', e);
      }
    }

    if (this._packagerNgrokUrl) {
      this.emit('packager-ngrok-will-disconnect', this._packagerNgrokUrl);
      try {
        await ngrok.promise.disconnect(this._packagerNgrokUrl);
        let oldNgrokUrl = this._packagerNgrokUrl;
        this._packagerNgrokUrl = null;
        // this._ngrokDisconnectedFulfill(oldNgrokUrl);
        // console.log("Disconnected ngrok");
        this.emit('packager-ngrok-disconnected', oldNgrokUrl);
      } catch (e) {
        console.error("Problem disconnecting packager ngrok:", e);
        // this._ngrokDisconnectedReject(e);
        this.emit('packager-ngrok-disconnect-err', e);
      }
    }
  }
github expo / exp / build / commands / archivedServe.js View on Github external
}

    // TODO: These two functions are sort of redundant
    var mainModulePath = yield urlUtil.guessMainModulePathAsync();
    var entryPoint = yield urlUtil.entryPointAsync();
    log(crayon.gray("Using mainModulePath of", mainModulePath, "and an entry point of", entryPoint));

    var ngrokSubdomain = argv['ngrok-subdomain'] || config.ngrok && config.ngrok.subdomain || undefined;
    var ngrokAuthToken = argv['ngrok-auth-token'] || config.ngrok && config.ngrok.authToken || undefined;

    var port = argv.port;
    if (port == null) {
      port = 9000 + Math.floor(Math.random() * 1000);
    }

    var urlP = ngrok.promise.connect({
      port: port,
      authtoken: ngrokAuthToken,
      subdomain: ngrokSubdomain
    });

    //var root = path.resolve(__dirname, '..', '..');
    var root = config.absolutePath;
    var packager = child_process.spawn(config.packagerPath, ["--port=" + port, "--root=" + root, "--assetRoots=" + root], {
      stdio: [process.stdin, 'pipe', process.stderr]
    });

    var outStream = new stream.Writable();
    outStream.buffer = '';
    outStream._write = function (chunk, encoding, done) {
      outStream.buffer += chunk.toString();
      done();
github expo / exp / src / serve / serveAsync.js View on Github external
async function _serve(opts) {

  var expSettings = await config.expInfoFile.readAsync();
  opts = opts || {};
  var port = opts.port || expSettings.port || await freeportAsync(6080);

  var pc = new PackagerController({port});
  var pcStart$ = pc.startAsync();
  var ngrokUrl$ = ngrok.promise.connect({port});

  try {
    var [_ready, ngrokBaseUrl, lanIp, entryPoint, mainModulePath] = await Promise.all([
      pc.packagerReady,
      ngrokUrl$,
      network.privateIpAsync(),
      urlUtil.entryPointAsync(),
      urlUtil.guessMainModulePathAsync(),
      ]);
  } catch (e) {

    // Shutdown packager
    var packagerShutdown$ = new Promise(function (fulfill, reject) {
      log("Attempting to shut down packager (" + pc._packager.pid + ")...");
      pc._packager.on('exit', function (code) {
        log("packager shut down.");
github expo / xde / src / application / packager.js View on Github external
async _startNgrokAsync() {
    return await ngrok.promise.connect(this.opts.port);
  }
github expo / exp / build / serve / serveAsync.js View on Github external
ngrokUrl$.then(function (ngrokBaseUrl) {
        log('Shutting down ngrok...');
        return ngrok.promise.disconnect(ngrokBaseUrl).then(function (x) {
          log('ngrok shutdown.');
          fulfill(x);
        }, function (err) {
          log.error('Disconnecting from ngrok failed', err);
        });
      })['catch'](function (err) {
        log.error('Failed to shutdown ngrok', err.message);
github expo / xde / build / application / packager.js View on Github external
value: _asyncToGenerator(function* () {
      return yield ngrok.promise.connect(this.opts.port);
    })
  }, {

ngrok

node wrapper for ngrok

BSD-2-Clause
Latest version published 2 years ago

Package Health Score

62 / 100
Full package analysis