<commit_before>var http = require('http'),
    express = require('express'),
    db = require('../db');

function configureExpressApp() {
  var app = express();
  app.use(genericErrorHandler);
  console.log(__dirname + '../../public');
  app.use(express.static(__dirname + '/../../public'));
  return app;

  function genericErrorHandler(err, req, res, next) {
    res.status(500);
    res.json({ error: "Something went wrong with reports generation" });
  }
}

function initializeRoutes(app, db) {
  require('./reports_routes')(app, db);
}

function startServer(app) {
  var port = 8080;
  var httpServer = http.createServer(app);
  httpServer.listen(port);
  console.log("Codebrag reporting server started on port", port);
  return httpServer;
}


db.initialize().then(function(db) {
  var app = configureExpressApp();
  initializeRoutes(app, db);
  startServer(app);
}).done();


<commit_msg>Add some basic auth to reporting server<commit_after>var http = require('http'),
    express = require('express'),
    db = require('../db');
var user = 'codebrag',
    password = <PASSWORD>';

function configureExpressApp() {
  var app = express();
  app.use(genericErrorHandler);
  app.use(express.basicAuth(user, password));
  app.use(express.static(__dirname + '/../../public'));
  return app;

  function genericErrorHandler(err, req, res, next) {
    res.status(500);
    res.json({ error: "Something went wrong with reports generation" });
  }
}

function initializeRoutes(app, db) {
  require('./reports_routes')(app, db);
}

function startServer(app) {
  var port = 8080;
  var httpServer = http.createServer(app);
  httpServer.listen(port);
  console.log("Codebrag reporting server started on port", port);
  return httpServer;
}


db.initialize().then(function(db) {
  var app = configureExpressApp();
  initializeRoutes(app, db);
  startServer(app);
}).done();



{'fraction_non_alphanumeric': 0.1625668449197861, 'fraction_numerical': 0.0074866310160427805, 'mean_word_length': 4.345714285714286, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '2882213', 'n_tokens_mistral': 588, 'n_tokens_neox': 571, 'n_words': 139}