<commit_before>var debug              = require('debug')('omnisplit');
var express            = require('express');
var session            = require('express-session');
var path               = require('path');
var favicon            = require('serve-favicon');
var logger             = require('morgan');
var redis              = require('redis');
var flash              = require('connect-flash');
var bodyParser         = require('body-parser');
var cookieParser       = require('cookie-parser');
var engine             = require('ejs-locals');
var passport           = require('passport');
var LocalStrategy      = require('passport-local');
var mongoose           = require('mongoose');
var mongooseRedisCache = require('mongoose-redis-cache');

var RedisStore = require('connect-redis')(session);

var client = redis.createClient();
var app = express();

var databaseUrl, redisOptions;

if (process.env.NODE_ENV == 'production') {
    //TODO: redis could be on another server
    databaseUrl = 'mongodb://' + process.env.DB_USER + ':' + process.env.DB_PASSWORD + '@ds<EMAIL>:41157/orderly_db';
    mongooseRedisCache(mongoose);
}
else { // Local dev
    databaseUrl = 'mongodb://orderly_test:test@127.0.0.1:27017/orderly_db';
    mongooseRedisCache(mongoose);
}

var db = mongoose.connection;
db.on('error', console.error);

mongoose.connect(databaseUrl, null, function(err) {
    if (err)
        debug(err);
    else
        if (process.env.NODE_ENV == 'PRODUCTION')
            debug('Connected to database.');
        else
            debug('Connected to local database.');
});

/***** CONFIGURATION *****/
require('./config/passport')(passport); // passport configuration

app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cookieParser());
app.use(flash());

app.use(express.static(path.join(__dirname, 'public')));

// Generate a secret key for JWTs
require('crypto').randomBytes(48, function(ex, buf) {
    app.set('jwtTokenSecret', buf.toString('hex'));
});

// view engine setup
app.engine('ejs', engine);
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));

// session setup
app.use(session({
    secret: 'session-secret',
    saveUninitialized: false,<commit_msg>DB connection message was incorrect<commit_after>var debug              = require('debug')('omnisplit');
var express            = require('express');
var session            = require('express-session');
var path               = require('path');
var favicon            = require('serve-favicon');
var logger             = require('morgan');
var redis              = require('redis');
var flash              = require('connect-flash');
var bodyParser         = require('body-parser');
var cookieParser       = require('cookie-parser');
var engine             = require('ejs-locals');
var passport           = require('passport');
var LocalStrategy      = require('passport-local');
var mongoose           = require('mongoose');
var mongooseRedisCache = require('mongoose-redis-cache');

var RedisStore = require('connect-redis')(session);

var client = redis.createClient();
var app = express();

var databaseUrl, redisOptions;

if (process.env.NODE_ENV == 'production') {
    //TODO: redis could be on another server
    databaseUrl = 'mongodb://' + process.env.DB_USER + ':' + process.env.DB_PASSWORD + '@ds041157.mongolab.com:41157/orderly_db';
    mongooseRedisCache(mongoose);
}
else { // Local dev
    databaseUrl = 'mongodb://orderly_test:test@127.0.0.1:27017/orderly_db';
    mongooseRedisCache(mongoose);
}

var db = mongoose.connection;
db.on('error', console.error);

mongoose.connect(databaseUrl, null, function(err) {
    if (err)
        debug(err);
    else
        if (process.env.NODE_ENV == 'production')
            debug('Connected to remote database.');
        else
            debug('Connected to local database.');
});

/***** CONFIGURATION *****/
require('./config/passport')(passport); // passport configuration

app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cookieParser());
app.use(flash());

app.use(express.static(path.join(__dirname, 'public')));

// Generate a secret key for JWTs
require('crypto').randomBytes(48, function(ex, buf) {
    app.set('jwtTokenSecret', buf.toString('hex'));
});

// view engine setup
app.engine('ejs', engine);
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));

// session setup
app.use(session({
    secret: 'session-secret',
    saveUninitialized: false,
{'fraction_non_alphanumeric': 0.16719982938792918, 'fraction_numerical': 0.008957133717210493, 'mean_word_length': 3.5357833655705995, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '4946932', 'n_tokens_mistral': 1433, 'n_tokens_neox': 1420, 'n_words': 296}