How to use the ngrok.connectAsync 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 kengz / aiva / src / env.js View on Github external
} else {
    var webhook = env[webhookKey]
    var subdomain
    if (webhook && webhook.match(/\/\/(\w+)\.ngrok/)) {
      subdomain = webhook.match(/\/\/(\w+)\.ngrok/)[1]
    }

    var ngrokOpts = _.pickBy({
      proto: 'http', // http|tcp|tls 
      addr: env['PORT'], // port or network address 
      subdomain: subdomain,
      authtoken: env['NGROK_AUTH']
    })
    log.debug(`ngrok options: ${JSON.stringify(ngrokOpts, null, 2)}`)

    return ngrok.connectAsync(ngrokOpts)
      .then((url) => {
        env[webhookKey] = url // update
        log.debug(`Set ${env['ADAPTER']} webhook url: ${url}:${env['PORT']}`)
        return env
      })
      .catch((e) => {
        log.error(`${JSON.stringify(e, null, 2)}`)
        return env
      })
  }
}

ngrok

node wrapper for ngrok

BSD-2-Clause
Latest version published 2 years ago

Package Health Score

62 / 100
Full package analysis