<commit_before>/**
 * The database module acts as a factory to instantiate and prepare the database engine that has been selected
 * for this api instance. It is intended to be simple but in case it gets more complicated over time we removed the
 * functionality from the app module.
 */
module.exports = (function(){
    'use strict';

    var config = require('../config'),
        db = {};

    try{
        db = require('./' + config.db.type);
    }
    catch(ex){
        console.log(ex);
        console.log('GRASSHOPPER NOT PROPERLY CONFIGURED. SEE DOCS ABOUT CONFIGURATION.');
    }
    return db;
})();

<commit_msg>Added event emitter for config error.<commit_after>/**
 * The database module acts as a factory to instantiate and prepare the database engine that has been selected
 * for this api instance. It is intended to be simple but in case it gets more complicated over time we removed the
 * functionality from the app module.
 */
module.exports = (function(){
    'use strict';

    var config = require('../config'),
        event = require('../event'),
        Strings = require('../strings'),
        strings = new Strings('en').group('errors'),
        err = require('../utils/error'),
        db = {};

    try{
        db = require('./' + config.db.type);
    }
    catch(ex){
        event.emit('error', { system: 'core' } , err(503, strings.configuration) );
    }
    return db;
})();


{'fraction_non_alphanumeric': 0.13083451202263083, 'fraction_numerical': 0.0021216407355021216, 'mean_word_length': 2.675324675324675, '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': '6489533', 'n_tokens_mistral': 390, 'n_tokens_neox': 376, 'n_words': 150}