<commit_before>var Hub = function () {
  'use strict';

  var Mongo = require('mongodb'),
      Mailer = require('nodemailer'),
      Api = require('./ApiGenerator');

  var _databases = {},
      _transporters = {},
      _activeDatabase,
      _activeMailer;
  
  function configure(options) { 
    var api;

    setDatabases(options.database);
    setTransporters(options.mailer);
 
    api = Api.registerModules(options.modules);
    api.get.mailer = getMailer;
    api.set.mailer = setTransporter;
    api.get.database = getDatabase;
    api.set.database = setDatabase;

    return api;
  }

  function setDatabases(databases) {
    for(var name in databases) {
      if(databases.hasOwnProperty(name)) {
        setDatabase(name, databases[name]);
      }
    }
  }

  function setDatabase(name, uri) {
    if(uri !== 'undefined') {
      Mongo.connect(uri, function (error, database) {
        if(error) {
          console.log('DB connection error'); 
          return;
        }

        addDatabase(name, database);

        if(name === 'default') {
          _activeDatabase = database;
        }
      });
    } else {
      _activeDatabase = getDatabase(name);
    }
  }

  function addDatabase(name, database) {
    _databases[name] = database; 
  }

  function getDatabase(name) {
    if(name !== 'undefined') {
      _activeDatabase = _databases[name];
    }

    return _activeDatabase;
  }

  function setTransporters(transporters) {
    for(var name in transporters) {
      if(transporters.hasOwnProperty(name)) {
        setTransporter(name, transporters[name]);
      }
    }
  }

  function setTransporter(name, config) {
    if(config !== 'undefined') {
      var transporter = Mailer.createTransport({
          service: config.service,
          auth: {
              user: config.email,
              pass: config.password
          }
      });
      
      addTransporter(name, transporter);

      if(name === 'default') {
        _activeMailer = transporter;
      }
    } else {
      _activeMailer = getMailer(name);
    }
  }

  function addTransporter(name, transporter) {
    _transporters[name] = transporter;
  }

  function getMailer(name) {
    if(name !== 'undefined') {
      _activeMailer = _transporters[name];
    }
    
    return _activeMailer;
  }

  return {
    configure: configure
  };
};

module.exports = Hub();<commit_msg>Fix database and mailer connectivity<commit_after>var Hub = function () {
  'use strict';

  var Mongo = require('mongodb').MongoClient,
      Mailer = require('nodemailer'),
      Api = require('./ApiGenerator');

  var _databases = {},
      _mailers = {};
  
  function configure(options) { 
    var api;

    setDatabases(options.database);
    setTransporters(options.mailer);
    
    api = Api.registerModules(options.modules);

    api.get = api.get || {};

    api.get.mailer = getMailer;
    api.get.database = getDatabase;

    return api;
  }

  function setDatabases(databases) {
    for(var name in databases) {
      if(databases.hasOwnProperty(name)) {
        setDatabase(name, databases[name].uri);
      }
    }
  }

  function setDatabase(name, uri) {
    Mongo.connect(uri, function (error, database) {
      if(error) {
        console.log('DB connection error'); 
        return;
      }

      addDatabase(name, database);
    });
  }

  function addDatabase(name, database) {
    _databases[name] = database; 
  }

  function getDatabase(name) {
    if(name !== 'undefined') {
      return _databases.default;
    }

    return _databases[name];
  }

  function setTransporters(transporters) {
    for(var name in transporters) {
      if(transporters.hasOwnProperty(name)) {
        setTransporter(name, transporters[name]);
      }
    }
  }

  function setTransporter(name, config) {
    var transporter = Mailer.createTransport({
        service: config.service,
        auth: {
            user: config.email,
            pass: <PASSWORD>
        }
    });
    
    addTransporter(name, transporter);
  }

  function addTransporter(name, transporter) {
    _mailers[name] = transporter;
  }

  function getMailer(name) {
    if(name !== 'undefined') {
      return _mailers.default;
    }
    
    return _mailers[name];
  }

  return {
    configure: configure
  };
};

module.exports = Hub();
{'fraction_non_alphanumeric': 0.12395348837209302, 'fraction_numerical': 0.0, 'mean_word_length': 2.457395498392283, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '4345346', 'n_tokens_mistral': 1359, 'n_tokens_neox': 1287, 'n_words': 243}