<commit_before>"use strict";

var config;

config = {
	bandwidth : {
		userId : process.env.BW_USER_ID,
		token  : process.env.BW_TOKEN,
		secret : process.env.BW_SECRET
	},

	isSet : function (prop) {
		try {
			var value;
			/* jshint ignore:start */
			value = eval(prop);
			/* jshint ignore:end */
			if (value === undefined || value === "") {
				throw new Error("variable not set: " + prop);
			}
			return true;
		}
		catch (ex) {
			console.error("Please set a value for config variable: " + prop);
			return false;
		}
	},

	validate : function () {
		var isValid = true;
		isValid = this.isSet("config.bandwidth.userId") && isValid;
		isValid = this.isSet("config.bandwidth.token") && isValid;
		isValid = this.isSet("config.bandwidth.secret") && isValid;
		return isValid;
	}
};

module.exports = config;<commit_msg>Use confidence for configuration management Use Joi to validate config settings<commit_after>"use strict";
var Promise = require("bluebird");
var Confidence = require("confidence");
var Joi = require("joi");

var configSettings;

function Config() {
	configSettings = {
		bandwidth : {
			userId : process.env.BW_USER_ID,
			token  : process.env.BW_TOKEN,
			secret : process.env.BW_SECRET
		}
	};
	this.store = new Confidence.Store(configSettings);
}

Config.prototype.validate = function () {
	var schema = Joi.object().keys({
		bandwidth : Joi.object().keys({
			userId : Joi.string().required(),
			token  : Joi.string().required(),
			secret : Joi.string().required()
		}),
	});

	var validatePromise = Promise.promisify(Joi.validate);
	return validatePromise(configSettings, schema);
};

module.exports = Config;

{'fraction_non_alphanumeric': 0.1487553126897389, 'fraction_numerical': 0.0, 'mean_word_length': 3.7768115942028984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3772764', 'n_tokens_mistral': 595, 'n_tokens_neox': 543, 'n_words': 122}