<commit_before>'use strict';

/**
 * Rhizome - The API that feeds grassroots movements
 *
 * @file app.js
 * @description
 * @module System
 * @author <NAME>
 *
 */

var express = require('express');
var methodOverride = require('method-override');
var bodyParser = require('body-parser');
var morgan = require('morgan');
var mongoose = require('mongoose');
var Model = require('./model/index');
var Routes = require('./routes/index');
var Config = require('./config');
var Logging = require('./logging');

/**
 * Express
 */
var app = module.exports = express();

/**
 * Configuration
 */
var configureDevelopment = () => {
  Config.env = 'dev';
  app.set('db-uri', `mongodb://${Config.RHIZOME_MONGO_URL_DEV}/${Config.app.code}-dev`);
  app.use(morgan('short'));
  app.set('port', Config.listenPort.dev);
};

var configureProduction = () => {
  Config.env = 'prod';
  app.set('db-uri', `mongodb://${Config.RHIZOME_MONGO_URL_PROD}/${Config.app.code}-prod`);
  app.use(morgan('short'));
  app.set('port', Config.listenPort.prod);
};

var configureTest = () => {
  Config.env = 'test';
  app.set('db-uri', `mongodb://${Config.RHIZOME_MONGO_URL_TEST}/${Config.app.code}-test`);
  app.use(morgan('short'));
  app.set('port', Config.listenPort.test);
};

var configureApp = env => {
  app.enable('trust proxy', 1);
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({extended: true}));
  app.use(methodOverride());

  app.use('static', express.static(`${Config.appDataPath}/public`));

  switch (env) {
    default:
    case 'development': {
      configureDevelopment();
    }
      break;
    case 'production': {
      configureProduction();
    }
      break;
    case 'test': {
      configureTest();
    }
      break;
  }
};

configureApp(app.get('env'));

/**
 *
 */
app.db = mongoose.connect(app.get('db-uri'));
app.db.connection.on('connected', () => {
  Logging.log(`${Config.app.title} listening on port ` +
              `${app.get('port')} in ${app.settings.env} mode.`, Logging.Constants.LogLevel.INFO);

  Model.init(app);
  Routes.init(app);

  app.server = app.listen(app.set('port'));
});
<commit_msg>- TWEAK: Remove the 'static' path prefix - the middleware doesn't seem to work with it.<commit_after>'use strict';

/**
 * Rhizome - The API that feeds grassroots movements
 *
 * @file app.js
 * @description
 * @module System
 * @author <NAME>
 *
 */

var express = require('express');
var methodOverride = require('method-override');
var bodyParser = require('body-parser');
var morgan = require('morgan');
var mongoose = require('mongoose');
var Model = require('./model/index');
var Routes = require('./routes/index');
var Config = require('./config');
var Logging = require('./logging');

/**
 * Express
 */
var app = module.exports = express();

/**
 * Configuration
 */
var configureDevelopment = () => {
  Config.env = 'dev';
  app.set('db-uri', `mongodb://${Config.RHIZOME_MONGO_URL_DEV}/${Config.app.code}-dev`);
  app.use(morgan('short'));
  app.set('port', Config.listenPort.dev);
};

var configureProduction = () => {
  Config.env = 'prod';
  app.set('db-uri', `mongodb://${Config.RHIZOME_MONGO_URL_PROD}/${Config.app.code}-prod`);
  app.use(morgan('short'));
  app.set('port', Config.listenPort.prod);
};

var configureTest = () => {
  Config.env = 'test';
  app.set('db-uri', `mongodb://${Config.RHIZOME_MONGO_URL_TEST}/${Config.app.code}-test`);
  app.use(morgan('short'));
  app.set('port', Config.listenPort.test);
};

var configureApp = env => {
  app.enable('trust proxy', 1);
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({extended: true}));
  app.use(methodOverride());

  app.use(express.static(`${Config.appDataPath}/public`));

  switch (env) {
    default:
    case 'development': {
      configureDevelopment();
    }
      break;
    case 'production': {
      configureProduction();
    }
      break;
    case 'test': {
      configureTest();
    }
      break;
  }
};

configureApp(app.get('env'));

/**
 *
 */
app.db = mongoose.connect(app.get('db-uri'));
app.db.connection.on('connected', () => {
  Logging.log(`${Config.app.title} listening on port ` +
              `${app.get('port')} in ${app.settings.env} mode.`, Logging.Constants.LogLevel.INFO);

  Model.init(app);
  Routes.init(app);

  app.server = app.listen(app.set('port'));
});

{'fraction_non_alphanumeric': 0.20898980537534753, 'fraction_numerical': 0.0004633920296570899, 'mean_word_length': 3.8396860986547083, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6767923', 'n_tokens_mistral': 1498, 'n_tokens_neox': 1455, 'n_words': 253}