samples/uiworkout.js
function bluemixServiceLookup(options, verbose) {
  var result = false;
  if (process.env.VCAP_SERVICES) {
    if (verbose) console.log('VCAP_SERVICES variable present in environment');
    var services = JSON.parse(process.env.VCAP_SERVICES);
    for (var key in services) {
      if (key.lastIndexOf(mqlightServiceName, 0) === 0) {
        var mqlightService = services[key][0];
        options.service = mqlightService.credentials.connectionLookupURI;
        options.user = mqlightService.credentials.username;
        options.password = mqlightService.credentials.password;
      } else if (key.lastIndexOf(messageHubServiceName, 0) === 0) {
        var messageHubService = services[key][0];
        options.service = messageHubService.credentials.mqlight_lookup_url;
        options.user = messageHubService.credentials.user;
        options.password = messageHubService.credentials.password;
      }
    }
    if (!options.hasOwnProperty('service') ||
        !options.hasOwnProperty('user') ||
        !options.hasOwnProperty('password')) {
      throw 'Error - Check that app is bound to service';
    }
    result = true;
  } else if (verbose) {
    console.log('VCAP_SERVICES variable not present in environment');
  }
  return result;
}
function bluemixServiceLookup(options, verbose) {
  var result = false;
  if (process.env.VCAP_SERVICES) {
    if (verbose) console.log('VCAP_SERVICES variable present in environment');
    var services = JSON.parse(process.env.VCAP_SERVICES);
    for (var key in services) {
      if (key.lastIndexOf(mqlightServiceName, 0) === 0) {
        var mqlightService = services[key][0];
        options.service = mqlightService.credentials.connectionLookupURI;
        options.user = mqlightService.credentials.username;
        options.password = mqlightService.credentials.password;
      } else if (key.lastIndexOf(messageHubServiceName, 0) === 0) {
        var messageHubService = services[key][0];
        options.service = messageHubService.credentials.mqlight_lookup_url;
        options.user = messageHubService.credentials.user;
        options.password = messageHubService.credentials.password;
      }
    }
    if (!options.hasOwnProperty('service') ||
        !options.hasOwnProperty('user') ||
        !options.hasOwnProperty('password')) {
      throw 'Error - Check that app is bound to service';
    }
    result = true;
  } else if (verbose) {
    console.log('VCAP_SERVICES variable not present in environment');
  }
  return result;
}
function bluemixServiceLookup ( options , verbose ) { var result = false ; if ( process . env . VCAP_SERVICES ) { if ( verbose ) console . log ( 'VCAP_SERVICES variable present in environment' ) ; var services = JSON . parse ( process . env . VCAP_SERVICES ) ; for ( var key in services ) { if ( key . lastIndexOf ( mqlightServiceName , 0 ) === 0 ) { var mqlightService = services [ key ] [ 0 ] ; options . service = mqlightService . credentials . connectionLookupURI ; options . user = mqlightService . credentials . username ; options . password = mqlightService . credentials . password ; } else if ( key . lastIndexOf ( messageHubServiceName , 0 ) === 0 ) { var messageHubService = services [ key ] [ 0 ] ; options . service = messageHubService . credentials . mqlight_lookup_url ; options . user = messageHubService . credentials . user ; options . password = messageHubService . credentials . password ; } } if ( ! options . hasOwnProperty ( 'service' ) || ! options . hasOwnProperty ( 'user' ) || ! options . hasOwnProperty ( 'password' ) ) { throw 'Error - Check that app is bound to service' ; } result = true ; } else if ( verbose ) { console . log ( 'VCAP_SERVICES variable not present in environment' ) ; } return result ; }
Checks to see if the application is running in IBM Bluemix. If it is, tries to retrieve connection details from the environent and populates the options object passed as an argument.
Checks to see if the application is running in IBM Bluemix . If it is tries to retrieve connection details from the environent and populates the options object passed as an argument .