{"size": 942, "ext": "js", "max_stars_repo_path": "api/models/live-db-connection.js", "max_stars_repo_name": "mss-parveensachdeva/interscreens", "max_stars_repo_stars_event_min_datetime": "2017-09-09T19:46:24.000Z", "max_stars_repo_stars_event_max_datetime": "2017-09-09T19:46:24.000Z", "max_issues_repo_path": "api/models/live-db-connection.js", "max_issues_repo_name": "mss-parveensachdeva/interscreens", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "api/models/live-db-connection.js", "max_forks_repo_name": "mss-parveensachdeva/interscreens", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 33.6428571429, "max_line_length": 135, "alphanum_fraction": 0.7314225053}
// load local VCAP configuration  and service credentials
var path  = require('path');

var vcapLocal, cloudant;
try {
	vcapLocal = require(path.join(__dirname,'../../config/live-db-config.json'));
	//console.log("vcapLocal >>>", vcapLocal);
} catch (e) {
	console.log("unable to load local configurations", e);
	throw new Error("unable to load local configurations");
}

const appEnvOpts = vcapLocal ? {
	vcap: vcapLocal
} : {};
const appEnv = appEnvOpts;

if (appEnv.vcap.services.cloudantNoSQLDB) {
	// Load the Cloudant library.
	var CloudantModule = require('cloudant');
	// Initialize database with credentials
	cloudant = CloudantModule(appEnv.vcap.services.cloudantNoSQLDB[0].credentials);
} else {
	console.log("Please check your configuration file" , path.join(__dirname,'../../config/live-db-config.json'), JSON.stringify(appEnv));
	throw new Error('Unabel to load both the database configurations');	
}

module.exports = cloudant;