<commit_before>/**
 * Extract all the necessary
 * configuration information
 * from either command line arguments
 * (which take priority) or environment
 * variables. Non-specified information
 * should prevent the application from starting,
 * unless there's a sensible default.
 * @module config
 */

// Parse arguments
var argv = require('minimist')(process.argv.slice(2));

// Extract values by priorities
var port = Number(argv.port || argv.p || process.env.HTTP_PORT);
var db_address = argv['db-address'] || process.env.DB_ADDRESS;

if (db_address === '' || db_address === undefined) {
  var db_host = argv['db-host'] || process.env.DB_HOST;
  var db_port = argv['db-port'] || process.env.DB_PORT || '27017';
  var db_name = argv['db-name'] || process.env.DB_NAME;

  if (db_host === undefined || db_name === undefined) {
    console.error('Please provide database information');
    process.exit(1);
  }

  db_address = 'mongodb://' + db_host + ':' + db_port + '/' + db_name;
}

// Validate values, where needed
if (isNaN(port) || port === 0) {
  console.error('Please provide a valid port number');
  process.exit(1);
}

module.exports = {
  port: port,
  db_address: db_address
}<commit_msg>Add a default port (8080)<commit_after>/**
 * Extract all the necessary
 * configuration information
 * from either command line arguments
 * (which take priority) or environment
 * variables. Non-specified information
 * should prevent the application from starting,
 * unless there's a sensible default.
 * @module config
 */

// Parse arguments
var argv = require('minimist')(process.argv.slice(2));

// Extract values by priorities
var port = Number(argv.port || argv.p || process.env.HTTP_PORT || '8080');
var db_address = argv['db-address'] || process.env.DB_ADDRESS;

if (db_address === '' || db_address === undefined) {
  var db_host = argv['db-host'] || process.env.DB_HOST;
  var db_port = argv['db-port'] || process.env.DB_PORT || '27017';
  var db_name = argv['db-name'] || process.env.DB_NAME;

  if (db_host === undefined || db_name === undefined) {
    console.error('Please provide database information');
    process.exit(1);
  }

  db_address = 'mongodb://' + db_host + ':' + db_port + '/' + db_name;
}

// Validate values, where needed
if (isNaN(port) || port === 0) {
  console.error('Please provide a valid port number');
  process.exit(1);
}

module.exports = {
  port: port,
  db_address: db_address
}
{'fraction_non_alphanumeric': 0.1549876339653751, 'fraction_numerical': 0.010717230008244023, 'mean_word_length': 4.109473684210526, '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': '7672190', 'n_tokens_mistral': 776, 'n_tokens_neox': 747, 'n_words': 211}