<commit_before>var fs = require('fs');
var path = require('path');

var bodyParser = require('body-parser');
var bcrypt = require('bcrypt');
var connectRedis = require('connect-redis');
var express = require('express');
var flash = require('express-flash');
var session = require('express-session');
var file = require('file');
var less = require('less');
var _ = require('lodash');
var passport = require('passport');
var localStrat = require('passport-local');
var Q = require('q');
var redis = require('redis');
var favicon = require('serve-favicon');
var compress = require('compression')

var dbApi = require(path.join(__dirname, 'database.js'));
var logger = require(path.join(__dirname, 'logger.js'));
var lolApi = require(path.join(__dirname, 'lol.js'));
var settings = require(path.join(__dirname, 'settings.js'));
var statsApi = require(path.join(__dirname, 'statistics.js'));

var VERSION = '1.0.2';

module.exports = {
  createApp: function(gatherStats) {
    var db = new dbApi(settings.postgre_url);
    var lol = new lolApi(settings.lol_api_key, settings.lol_burst_requests, settings.lol_burst_period);
    var stats = new statsApi(db, lol);

    var promise = db.init().then(function() {
      return lol.init();
    }).then(function() {
      file.walkSync(path.join(__dirname, 'less'), function(dirPath, dirs, files) {
        for (var i = 0; i < files.length; i++) {
          var filePath = path.join(dirPath, files[i]);
          less.render(fs.readFileSync(filePath).toString('utf8'), {
            paths: [path.join(__dirname, 'less')],
            filename: filePath,
            compress: false
          }, function(err, output) {
            if (err) {
              throw err;
            }

            var outFileName = path.join(__dirname, 'public/css', path.basename(files[i], '.less') + '.css');
            fs.writeFileSync(outFileName, output.css);
          });
        }
      });
    }).then(function() {
      var app = express();
      var redisStore = connectRedis(session);

      app.set('views', path.join(__dirname, 'views'));
      app.set('view engine', 'jade');

      app.use(express.static(path.join(__dirname, 'public')));
      app.use(favicon(path.join(__dirname, 'public/img/favicon.ico')));
      app.use(bodyParser.json());
      app.use(bodyParser.urlencoded({
        extended: true,
      }));
      app.use(session({
        secret: settings.secret_key,
        resave: false,
        saveUninitialized: true,
        store: new redisStore({
          host: 'localhost',
          port: '6379'
        })
      }));
      app.use(flash());
      app.use(passport.initialize());
      app.use(passport.session());
      app.use(compress());
      
      passport.use(new localStrat(function(username, password, done) {
        db.getUser(username).done(function(user) {
          if (!user) {
            return done(null, false);<commit_msg>Fixed formatting issues.<commit_after>var fs = require('fs');
var path = require('path');

var bodyParser = require('body-parser');
var bcrypt = require('bcrypt');
var compress = require('compression');
var connectRedis = require('connect-redis');
var express = require('express');
var flash = require('express-flash');
var session = require('express-session');
var file = require('file');
var less = require('less');
var _ = require('lodash');
var passport = require('passport');
var localStrat = require('passport-local');
var Q = require('q');
var redis = require('redis');
var favicon = require('serve-favicon');

var dbApi = require(path.join(__dirname, 'database.js'));
var logger = require(path.join(__dirname, 'logger.js'));
var lolApi = require(path.join(__dirname, 'lol.js'));
var settings = require(path.join(__dirname, 'settings.js'));
var statsApi = require(path.join(__dirname, 'statistics.js'));

var VERSION = '1.0.2';

module.exports = {
  createApp: function(gatherStats) {
    var db = new dbApi(settings.postgre_url);
    var lol = new lolApi(settings.lol_api_key, settings.lol_burst_requests, settings.lol_burst_period);
    var stats = new statsApi(db, lol);

    var promise = db.init().then(function() {
      return lol.init();
    }).then(function() {
      file.walkSync(path.join(__dirname, 'less'), function(dirPath, dirs, files) {
        for (var i = 0; i < files.length; i++) {
          var filePath = path.join(dirPath, files[i]);
          less.render(fs.readFileSync(filePath).toString('utf8'), {
            paths: [path.join(__dirname, 'less')],
            filename: filePath,
            compress: false
          }, function(err, output) {
            if (err) {
              throw err;
            }

            var outFileName = path.join(__dirname, 'public/css', path.basename(files[i], '.less') + '.css');
            fs.writeFileSync(outFileName, output.css);
          });
        }
      });
    }).then(function() {
      var app = express();
      var redisStore = connectRedis(session);

      app.set('views', path.join(__dirname, 'views'));
      app.set('view engine', 'jade');

      app.use(express.static(path.join(__dirname, 'public')));
      app.use(favicon(path.join(__dirname, 'public/img/favicon.ico')));
      app.use(bodyParser.json());
      app.use(bodyParser.urlencoded({
        extended: true,
      }));
      app.use(session({
        secret: settings.secret_key,
        resave: false,
        saveUninitialized: true,
        store: new redisStore({
          host: 'localhost',
          port: '6379'
        })
      }));
      app.use(flash());
      app.use(passport.initialize());
      app.use(passport.session());
      app.use(compress());

      passport.use(new localStrat(function(username, password, done) {
        db.getUser(username).done(function(user) {
          if (!user) {
            return done(null, false);
{'fraction_non_alphanumeric': 0.1659779614325069, 'fraction_numerical': 0.0030991735537190084, 'mean_word_length': 3.0565642458100557, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5534304', 'n_tokens_mistral': 1775, 'n_tokens_neox': 1754, 'n_words': 371}