<commit_before>/**
 * bootstrap.js
 * Loads the configurations, setup Express, the routes, starts the database
 * connection while setting up the models and starts the application.
 *
 * @author  <NAME> <<EMAIL>>
 * @package valdron
 */

(function(){
  'use strict';

  // Load up the depencencies.
  var async = require('async'),
      fs = require('fs'),
      path = require('path'),
      walker = require('walk');

  // Export the main app function.
  module.exports = function(callback){

    var app = require('express')(),
        server = require('http').createServer(app);

    // We want to setup our logger first, then the configs.
    async.series([

      // Setup the Winston, our logger.
      function(next){

        var winston = require('winston');

        // Create new transport and handlers for the logger.
        var transports = [
          new winston.transports.Console({
            colorize: true,
            timestamp: true,
            level: 'info'
          }),
          new winston.transports.File({
            filename: path.join(process.cwd(), 'log', 'debug.log'),
            level: 'data',
            maxsize: 2 * 1024 * 1024
          })
        ];

        var exceptionHandlers = [
          new winston.transports.Console({
            colorize: true,
            timestamp: true
          }),
          new winston.transports.File({
            filename: path.join(process.cwd(), 'log', 'exceptions.log'),
            maxsize: 2 * 1024 * 1024
          })
        ];

        // Make sure we have a logs directory, we use synchronous because we're 
        // at startup, so blocking isn't a big problem.
        if (!fs.existsSync(path.join(process.cwd(), 'log'))) {
          fs.mkdirSync(path.join(process.cwd(), 'log'), 511); // 0777 in decimal
        }

        // Create our logger and make it global to the application.
        app.logger = new winston.Logger({
            transports: transports,
            exceptionHandlers: exceptionHandlers
        });

        app.logger.info('Logger initialized!');

        return next();

      },

      // Load up our configs.
      function(next){

        app.logger.info('Loading config files...');

        if (fs.existsSync(path.join(process.cwd(), 'config', process.env.NODE_ENV))) {

          // Load the environment specific config.
          app.config = require(path.join(process.cwd(), 'config', process.env.NODE_ENV))();

        } else {

          app.config = {};

          if (process.env.DB) {

            // Get our connection information.
            var info = process.env.db.match(/([A-z].+):\/\/([A-z0-9\.].+):([A-z0-9\.].+)@([A-z0-9\.].+):([0-9].+)\/(.*)/);

            app.config.db = {
             driver: info[1],<commit_msg>changed DB to DATABASE_URL, cuz that's what heroku passes us<commit_after>/**
 * bootstrap.js
 * Loads the configurations, setup Express, the routes, starts the database
 * connection while setting up the models and starts the application.
 *
 * @author  <NAME> <<EMAIL>>
 * @package valdron
 */

(function(){
  'use strict';

  // Load up the depencencies.
  var async = require('async'),
      fs = require('fs'),
      path = require('path'),
      walker = require('walk');

  // Export the main app function.
  module.exports = function(callback){

    var app = require('express')(),
        server = require('http').createServer(app);

    // We want to setup our logger first, then the configs.
    async.series([

      // Setup the Winston, our logger.
      function(next){

        var winston = require('winston');

        // Create new transport and handlers for the logger.
        var transports = [
          new winston.transports.Console({
            colorize: true,
            timestamp: true,
            level: 'info'
          }),
          new winston.transports.File({
            filename: path.join(process.cwd(), 'log', 'debug.log'),
            level: 'data',
            maxsize: 2 * 1024 * 1024
          })
        ];

        var exceptionHandlers = [
          new winston.transports.Console({
            colorize: true,
            timestamp: true
          }),
          new winston.transports.File({
            filename: path.join(process.cwd(), 'log', 'exceptions.log'),
            maxsize: 2 * 1024 * 1024
          })
        ];

        // Make sure we have a logs directory, we use synchronous because we're 
        // at startup, so blocking isn't a big problem.
        if (!fs.existsSync(path.join(process.cwd(), 'log'))) {
          fs.mkdirSync(path.join(process.cwd(), 'log'), 511); // 0777 in decimal
        }

        // Create our logger and make it global to the application.
        app.logger = new winston.Logger({
            transports: transports,
            exceptionHandlers: exceptionHandlers
        });

        app.logger.info('Logger initialized!');

        return next();

      },

      // Load up our configs.
      function(next){

        app.logger.info('Loading config files...');

        if (fs.existsSync(path.join(process.cwd(), 'config', process.env.NODE_ENV))) {

          // Load the environment specific config.
          app.config = require(path.join(process.cwd(), 'config', process.env.NODE_ENV))();

        } else {

          app.config = {};

          if (process.env.DATABASE_URL) {

            // Get our connection information.
            var info = process.env.DATABASE_URL.match(/([A-z].+):\/\/([A-z0-9\.].+):([A-z0-9\.].+)@([A-z0-9\.].+):([0-9].+)\/(.*)/);

            app.config.db = {
             driver: info[1],
{'fraction_non_alphanumeric': 0.14646374216651745, 'fraction_numerical': 0.012175470008952551, 'mean_word_length': 1.906347554630593, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6389383', 'n_tokens_mistral': 1678, 'n_tokens_neox': 1553, 'n_words': 424}