<commit_before>/**
 * Module dependencies.
 */

var express = require('express')
    , fs = require('fs')
    , mongoose = require('mongoose')
    , exec = require('child_process').exec
    , https = require('https');


var app = module.exports = express();

// Configuration

app.configure(function(){
    app.use(express.bodyParser({
        uploadDir: __dirname + '/../app/tmp',
        keepExtensions: true
    }));
    app.use(express.methodOverride());
    app.use(app.router);
    app.use(express.static(__dirname + '/../app'));

    // Copy the schemas to somewhere they can be served
    exec('cp '+__dirname+'/../server/models/* '+__dirname+'/../app/code/',
        function (error, stdout, stderr) {
            if (error !== null) {
                console.log('Error copying models : ' + error + ' (Code = ' + error.code + '    ' + error.signal + ') : ' + stderr + ' : ' + stdout);
            }
        });
});

app.configure('development', function(){
//    mongoose.set('debug',true);
    app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
    mongoose.connect('mongodb://localhost/forms-ng_dev');
//    mongoose.connect('mongodb://theworld:<EMAIL>:10053/formsng');
//    console.log('************    Using LIVE data  ***************')
});

app.configure('test', function(){
    app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
    mongoose.connect('mongodb://localhost/forms-ng_test');

    // Try and figure out what is wrong with tests under Travis CI
    var execSync = require('execSync');
    console.log("dirname",execSync.stdout('ls '+__dirname));
    console.log("app dir",execSync.stdout('ls '+__dirname+'/..'));
    console.log("test",execSync.stdout('ls '+__dirname+'/../test'));
    console.log("e2e",execSync.stdout('ls '+__dirname+'/../e2e'));
    console.log("data",execSync.stdout('ls '+__dirname+'/../e2e/data'));
    var data_path = __dirname + '/../test/e2e/data';
    var data_files = fs.readdirSync(data_path);
    data_files.forEach(function(file){
        var fname = data_path+'/'+file;
        if (fs.statSync(fname).isFile()) {
            exec('mongoimport --db forms-ng_test --drop --collection '+ file.slice(0,1)+'s --jsonArray < ' + fname,
                function (error, stdout, stderr) {
                    if (error !== null) {
                        console.log('Error importing models : ' + error + ' (Code = ' + error.code + '    ' + error.signal + ') : ' + stderr + ' : ' + stdout);
                    }
                });
        }
    });
});

app.configure('production', function(){
    console.log('Production mode');
    app.use(express.errorHandler());
    mongoose.connect('mongodb://theworld:<EMAIL>:10053/formsng');
});

var ensureAuthenticated = function (req, res, next) {
    // Here you can do authentication using things like
    //      req.ip
    //      req.route
    //      req.url<commit_msg>Temp commit to try and figure out what is wrong with tests under Travis CI (properly this time)<commit_after>/**
 * Module dependencies.
 */

var express = require('express')
    , fs = require('fs')
    , mongoose = require('mongoose')
    , exec = require('child_process').exec
    , https = require('https');


var app = module.exports = express();

// Configuration

app.configure(function(){
    app.use(express.bodyParser({
        uploadDir: __dirname + '/../app/tmp',
        keepExtensions: true
    }));
    app.use(express.methodOverride());
    app.use(app.router);
    app.use(express.static(__dirname + '/../app'));

    // Copy the schemas to somewhere they can be served
    exec('cp '+__dirname+'/../server/models/* '+__dirname+'/../app/code/',
        function (error, stdout, stderr) {
            if (error !== null) {
                console.log('Error copying models : ' + error + ' (Code = ' + error.code + '    ' + error.signal + ') : ' + stderr + ' : ' + stdout);
            }
        });
});

app.configure('development', function(){
//    mongoose.set('debug',true);
    app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
    mongoose.connect('mongodb://localhost/forms-ng_dev');
//    mongoose.connect('mongodb://theworld:<EMAIL>:10053/formsng');
//    console.log('************    Using LIVE data  ***************')
});

app.configure('test', function(){
    app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
    mongoose.connect('mongodb://localhost/forms-ng_test');

    // Try and figure out what is wrong with tests under Travis CI
    var execSync = require('execSync');
    console.log("dirname",execSync.stdout('ls '+__dirname));
    console.log("app dir",execSync.stdout('ls '+__dirname+'/..'));
    console.log("test",execSync.stdout('ls '+__dirname+'/../test'));
    console.log("e2e",execSync.stdout('ls '+__dirname+'/../test/e2e'));
    console.log("data",execSync.stdout('ls '+__dirname+'/../test/e2e/data'));
    var data_path = __dirname + '/../test/e2e/data';
    var data_files = fs.readdirSync(data_path);
    data_files.forEach(function(file){
        var fname = data_path+'/'+file;
        if (fs.statSync(fname).isFile()) {
            exec('mongoimport --db forms-ng_test --drop --collection '+ file.slice(0,1)+'s --jsonArray < ' + fname,
                function (error, stdout, stderr) {
                    if (error !== null) {
                        console.log('Error importing models : ' + error + ' (Code = ' + error.code + '    ' + error.signal + ') : ' + stderr + ' : ' + stdout);
                    }
                });
        }
    });
});

app.configure('production', function(){
    console.log('Production mode');
    app.use(express.errorHandler());
    mongoose.connect('mongodb://theworld:<EMAIL>:10053/formsng');
});

var ensureAuthenticated = function (req, res, next) {
    // Here you can do authentication using things like
    //      req.ip
    //      req.route
    //      req.url
{'fraction_non_alphanumeric': 0.19258010118043845, 'fraction_numerical': 0.005396290050590219, 'mean_word_length': 2.706875, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, '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': '6564886', 'n_tokens_mistral': 1840, 'n_tokens_neox': 1793, 'n_words': 348}