How to use the chimp.ddp0 function in chimp

To help you get started, we’ve selected a few chimp 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 TheBrainFamily / chimpy / src / lib / chimp-helper.js View on Github external
global.wrapAsync = wrapAsync;
    global.wrapAsyncObject = wrapAsyncObject;

    // give users access the request module
    global.request = request;
    _.extend(global, wrapAsyncObject(global, ['request'], {
      syncByDefault: booleanHelper.isTruthy(process.env['chimp.sync'])
    }));

    // Give the user access to Promise functions. E.g. Promise.all.
    global.Promise = Promise;

    if (booleanHelper.isTruthy(process.env['chimp.ddp0'])) {
      // add .instances[] property onto the DDP object. this way
      // global.server is usable, but so is server.instances[0] as an alias for when using multiple ddp servers
      global.ddp = new DDP(process.env['chimp.ddp0']).connect();
      // add on instances t
      global.ddp.instances = [];
      for(let key in process.env) {
        if(key.indexOf('chimp.ddp') !== -1 ) {
          var index = key.match(/chimp.ddp(.*)/)[1];
          if (index) {
            global.ddp.instances.push(new DDP(process.env['chimp.ddp' + index]).connect());
          }
        }
      }
    }
  },
github TheBrainFamily / chimpy / src / __tests__ / ddp-spec.js View on Github external
it('sets ROOT_URL env var to be the chimp.ddp env var', function () {
      process.env['chimp.ddp0'] = 'http://here.com:3000';
      new DDP();
      expect(process.env.ROOT_URL).toEqual('http://here.com:3000');
    });
    it('does not change the ROOT_URL when it is provided', function () {
github TheBrainFamily / chimpy / src / lib / chimp-helper.js View on Github external
expect('DDP Not Connected').to.equal('', 'You tried to use a DDP connection but it' +
            ' has not been configured. Be sure to pass --ddp=');
        };
        global.ddp0 = {
          call: noDdp,
          apply: noDdp,
          execute: noDdp
        };
        log.debug('[chimp][helper] DDP not required');
      }
    };

    try {
      setupBrowser();
      initBrowser();
      if (booleanHelper.isTruthy(process.env['chimp.ddp0'])) {
        setupDdp();
      }
    } catch (error) {
      log.error('[chimp][helper] setupBrowserAndDDP had error');
      log.error(error);
      log.error(error.stack);
      exit(2);
    }
  },
github TheBrainFamily / chimpy / src / lib / chimp-helper.js View on Github external
var setupDdp = function () {
      log.debug('[chimp][helper] setup DDP');
      if (process.env['chimp.ddp0']) {
        try {
          log.debug('[chimp][helper] connecting via DDP to', process.env['chimp.ddp0']);
          global.ddp.connectSync();
          addServerExecute(global.ddp);
          for(let i = 0; i < global.ddp.instances.length; i++) {
            log.debug('[chimp][helper] connecting via DDP to ' + global.ddp.instances[i]._original.host + ':' + global.ddp.instances[i]._original.port);
            global.ddp.instances[i].connectSync();
            addServerExecute(global.ddp.instances[i]);
          }
          log.debug('[chimp][helper] connecting via DDP had no error');
        } catch (error) {
          let errorMessage = error;
          if (_.isObject(error)) {
            if (error.code === 'ECONNREFUSED') {
              log.error('[chimp][helper] Cannot connect to Meteor. Please check if your application is up and running on ' + error.address + ' port ' + error.port);
            }
            errorMessage = error.code;
          }
github TheBrainFamily / chimpy / src / lib / chimp-helper.js View on Github external
var setupDdp = function () {
      log.debug('[chimp][helper] setup DDP');
      if (process.env['chimp.ddp0']) {
        try {
          log.debug('[chimp][helper] connecting via DDP to', process.env['chimp.ddp0']);
          global.ddp.connectSync();
          addServerExecute(global.ddp);
          for(let i = 0; i < global.ddp.instances.length; i++) {
            log.debug('[chimp][helper] connecting via DDP to ' + global.ddp.instances[i]._original.host + ':' + global.ddp.instances[i]._original.port);
            global.ddp.instances[i].connectSync();
            addServerExecute(global.ddp.instances[i]);
          }
          log.debug('[chimp][helper] connecting via DDP had no error');
        } catch (error) {
          let errorMessage = error;
          if (_.isObject(error)) {
            if (error.code === 'ECONNREFUSED') {
              log.error('[chimp][helper] Cannot connect to Meteor. Please check if your application is up and running on ' + error.address + ' port ' + error.port);
            }
github TheBrainFamily / chimpy / src / lib / chimp.js View on Github external
function handleDdpOption(options) {
  if (typeof options.ddp === 'string') {
    process.env['chimp.ddp0'] = String(options.ddp);
    return;
  }
  if (Array.isArray(options.ddp)) {
    options.ddp.forEach(function(val, index){
      process.env['chimp.ddp' + index] = String(val);
    });
  }
}
github TheBrainFamily / chimpy / src / lib / ddp.js View on Github external
function DDP(url) {
  log.debug('[chimp][ddp] creating DDP wrapper');
  process.env.ROOT_URL = process.env.ROOT_URL || process.env['chimp.ddp0'];

  if (!url) {
    this.url = this._getUrl(process.env['chimp.ddp0']);
  } else {
    this.url = this._getUrl(url);
  }
}
github TheBrainFamily / chimpy / src / lib / ddp.js View on Github external
function DDP(url) {
  log.debug('[chimp][ddp] creating DDP wrapper');
  process.env.ROOT_URL = process.env.ROOT_URL || process.env['chimp.ddp0'];

  if (!url) {
    this.url = this._getUrl(process.env['chimp.ddp0']);
  } else {
    this.url = this._getUrl(url);
  }
}