lib/consul.js
function Consul(opts) {
  if (!(this instanceof Consul)) {
    return new Consul(opts);
  }

  opts = utils.defaults({}, opts);

  if (!opts.baseUrl) {
    opts.baseUrl = (opts.secure ? 'https:' : 'http:') + '//' +
      (opts.host || '127.0.0.1') + ':' +
      (opts.port || 8500) + '/v1';
  }
  opts.name = 'consul';
  opts.type = 'json';

  if (opts.defaults) {
    var defaults = utils.defaultCommonOptions(opts.defaults);
    if (defaults) this._defaults = defaults;
  }
  delete opts.defaults;

  papi.Client.call(this, opts);

  this.acl = new Consul.Acl(this);
  this.agent = new Consul.Agent(this);
  this.catalog = new Consul.Catalog(this);
  this.event = new Consul.Event(this);
  this.health = new Consul.Health(this);
  this.kv = new Consul.Kv(this);
  this.query = new Consul.Query(this);
  this.session = new Consul.Session(this);
  this.status = new Consul.Status(this);

  try {
    if (opts.promisify) {
      if (typeof opts.promisify === 'function') {
        papi.tools.promisify(this, opts.promisify);
      } else {
        papi.tools.promisify(this);
      }
    }
  } catch (err) {
    err.message = 'promisify: ' + err.message;
    throw err;
  }
}
function Consul(opts) {
  if (!(this instanceof Consul)) {
    return new Consul(opts);
  }

  opts = utils.defaults({}, opts);

  if (!opts.baseUrl) {
    opts.baseUrl = (opts.secure ? 'https:' : 'http:') + '//' +
      (opts.host || '127.0.0.1') + ':' +
      (opts.port || 8500) + '/v1';
  }
  opts.name = 'consul';
  opts.type = 'json';

  if (opts.defaults) {
    var defaults = utils.defaultCommonOptions(opts.defaults);
    if (defaults) this._defaults = defaults;
  }
  delete opts.defaults;

  papi.Client.call(this, opts);

  this.acl = new Consul.Acl(this);
  this.agent = new Consul.Agent(this);
  this.catalog = new Consul.Catalog(this);
  this.event = new Consul.Event(this);
  this.health = new Consul.Health(this);
  this.kv = new Consul.Kv(this);
  this.query = new Consul.Query(this);
  this.session = new Consul.Session(this);
  this.status = new Consul.Status(this);

  try {
    if (opts.promisify) {
      if (typeof opts.promisify === 'function') {
        papi.tools.promisify(this, opts.promisify);
      } else {
        papi.tools.promisify(this);
      }
    }
  } catch (err) {
    err.message = 'promisify: ' + err.message;
    throw err;
  }
}
function Consul ( opts ) { if ( ! ( this instanceof Consul ) ) { return new Consul ( opts ) ; } opts = utils . defaults ( { } , opts ) ; if ( ! opts . baseUrl ) { opts . baseUrl = ( opts . secure ? 'https:' : 'http:' ) + '//' + ( opts . host || '127.0.0.1' ) + ':' + ( opts . port || 8500 ) + '/v1' ; } opts . name = 'consul' ; opts . type = 'json' ; if ( opts . defaults ) { var defaults = utils . defaultCommonOptions ( opts . defaults ) ; if ( defaults ) this . _defaults = defaults ; } delete opts . defaults ; papi . Client . call ( this , opts ) ; this . acl = new Consul . Acl ( this ) ; this . agent = new Consul . Agent ( this ) ; this . catalog = new Consul . Catalog ( this ) ; this . event = new Consul . Event ( this ) ; this . health = new Consul . Health ( this ) ; this . kv = new Consul . Kv ( this ) ; this . query = new Consul . Query ( this ) ; this . session = new Consul . Session ( this ) ; this . status = new Consul . Status ( this ) ; try { if ( opts . promisify ) { if ( typeof opts . promisify === 'function' ) { papi . tools . promisify ( this , opts . promisify ) ; } else { papi . tools . promisify ( this ) ; } } } catch ( err ) { err . message = 'promisify: ' + err . message ; throw err ; } }
Initialize a new `Consul` client.
Initialize a new Consul client .