<commit_before>var _ = require('lodash');
var console = require('./consoleService')();
var nconf = require('nconf');
var auth = require('http-auth'); // @see https://github.com/gevorg/http-auth

var allAchievibitConfigNames = [
  'firebaseType',
  'firebaseProjectId',
  'firebasePrivateKeyId',
  'firebasePrivateKey',
  'firebaseClientEmail',
  'firebaseClientId',
  'firebaseAuthUri',
  'firebaseTokenUri',
  'firebaseAPx509CU',
  'firebaseCx509CU',
  'port',
  'databaseUrl',
  'stealth',
  'testDB',
  'logsUsername',
  'logsPassword',
  'ngrokToken'
];

// look for config in:
nconf
  .argv()
  .env({whitelist: allAchievibitConfigNames})
  .file({ file: 'privateConfig.json' });

var configService = function() {

  var shouldSaveToFile = nconf.get('savePrivate');

  if (shouldSaveToFile) {
    _.forEach(allAchievibitConfigNames, function(varName) {
      nconf.set(varName, nconf.get(varName));
      var tmp = {};
      tmp[varName] =  nconf.get(varName);
      console.log('got this config', tmp);
    });

    nconf.save(function (err) {
      if (err) {
        console.error('problem saving private configuration');
      } else {
        console.info('PERSONAL CONFIG SAVED! DELETE WHEN FINISHED!');
      }
    });
  }

  return {
    get: function(name) {
      return nconf.get(name);
    },
    haveLogsAuth: !_.isNil(nconf.get('logsUsername')),
    createLogsAuthForExpress: function() {<commit_msg>fix the debugging log (#108)<commit_after>var _ = require('lodash');
var console = require('./consoleService')();
var nconf = require('nconf');
var auth = require('http-auth'); // @see https://github.com/gevorg/http-auth

var allAchievibitConfigNames = [
  'firebaseType',
  'firebaseProjectId',
  'firebasePrivateKeyId',
  'firebasePrivateKey',
  'firebaseClientEmail',
  'firebaseClientId',
  'firebaseAuthUri',
  'firebaseTokenUri',
  'firebaseAPx509CU',
  'firebaseCx509CU',
  'port',
  'databaseUrl',
  'stealth',
  'testDB',
  'logsUsername',
  'logsPassword',
  'ngrokToken'
];

// look for config in:
nconf
  .argv()
  .env({whitelist: allAchievibitConfigNames})
  .file({ file: 'privateConfig.json' });

var configService = function() {

  var shouldSaveToFile = nconf.get('savePrivate');

  _.forEach(allAchievibitConfigNames, function(varName) {
    var tmp = {};
    tmp[varName] =  nconf.get(varName);
    console.log('got this config', tmp);
  });

  if (shouldSaveToFile) {
    _.forEach(allAchievibitConfigNames, function(varName) {
      nconf.set(varName, nconf.get(varName));
    });

    nconf.save(function (err) {
      if (err) {
        console.error('problem saving private configuration');
      } else {
        console.info('PERSONAL CONFIG SAVED! DELETE WHEN FINISHED!');
      }
    });
  }

  return {
    get: function(name) {
      return nconf.get(name);
    },
    haveLogsAuth: !_.isNil(nconf.get('logsUsername')),
    createLogsAuthForExpress: function() {
{'fraction_non_alphanumeric': 0.1565934065934066, 'fraction_numerical': 0.005151098901098901, 'mean_word_length': 3.814876033057851, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '2250528', 'n_tokens_mistral': 1033, 'n_tokens_neox': 1002, 'n_words': 180}