<commit_before>
var path = require('path'),
    i18n = require('i18n');

/*
  Config system:

  config/
    system/
      config.json
      config.js
    development/
      config.json
      config.js
    production /
      config.json
      config.js

  1 - Source config.json & merge ENV/config.json
  2 - Require system/config.js
  3 - Requrie ENV/config.js
 */

console.log('[Config] Loading config.json');
var config = require(path.resolve('config/system', 'config.json'));

// merge base config with environment config
var envConfig = require(path.resolve('config/' + process.env.NODE_ENV, 'config.json'));
config = Object.merge(config, envConfig);

// properties to be resolved
var resolveProps = 'models,views,controllers,routes,locales,static'.split(',');
resolveProps.forEach(function(prop){
  app.set(prop, path.resolve(config[prop]));
});

// static properties, everything else
Object.keys(config, function(prop, value) {
  if (resolveProps.indexOf(prop) > 0) return;
  app.set(prop, value);
});

console.log('[Config] Configure base middleware');
app.use( require('body-parser').urlencoded({ extended: true }) );
app.use( require('body-parser').json() );
app.use( require('cookie-parser')() );
app.use( require('method-override')() );
app.use( require('express-session')(app.settings['express-session']) );
app.use( require('csurf')() );

/* --------------------------
 * Localization
 * --------------------------------------- */
i18n.configure(Object.merge({directory: app.settings.locales}, app.settings.i18n || {} ));
app.use(i18n.init);

/* --------------------------
 * Dynamic locals
 * --------------------------------------- */
app.use(function(req, res, next) {
  res.locals.path = req.path;
  res.locals.url = req.url;
  res.locals.user = req.user;
  res.locals.csrftoken = req.csrfToken();
  next();
});

/* --------------------------
 * Static locals
 * --------------------------------------- */
app.locals = {
  title: app.settings.title,
  version: app.settings.version,
  environment: app.settings.environment,<commit_msg>Fixed merge bug (need deep merge)<commit_after>
var path = require('path'),
    i18n = require('i18n');

/*
  Config system:

  config/
    system/
      config.json
      config.js
    development/
      config.json
      config.js
    production /
      config.json
      config.js

  1 - Source config.json & merge ENV/config.json
  2 - Require system/config.js
  3 - Requrie ENV/config.js
 */

console.log('[Config] Loading config.json');
var config = require(path.resolve('config/system', 'config.json'));

// merge base config with environment config
var envConfig = require(path.resolve('config/' + process.env.NODE_ENV, 'config.json'));
config = Object.merge(config, envConfig, true);

// properties to be resolved
var resolveProps = 'models,views,controllers,routes,locales,static'.split(',');
resolveProps.forEach(function(prop){
  app.set(prop, path.resolve(config[prop]));
});

// static properties, everything else
Object.keys(config, function(prop, value) {
  if (resolveProps.indexOf(prop) > 0) return;
  app.set(prop, value);
});

console.log('[Config] Configure base middleware');
app.use( require('body-parser').urlencoded({ extended: true }) );
app.use( require('body-parser').json() );
app.use( require('cookie-parser')() );
app.use( require('method-override')() );
app.use( require('express-session')(app.settings['express-session']) );
app.use( require('csurf')() );

/* --------------------------
 * Localization
 * --------------------------------------- */
i18n.configure(Object.merge({directory: app.settings.locales}, app.settings.i18n || {}, true ));
app.use(i18n.init);

/* --------------------------
 * Dynamic locals
 * --------------------------------------- */
app.use(function(req, res, next) {
  res.locals.path = req.path;
  res.locals.url = req.url;
  res.locals.user = req.user;
  res.locals.csrftoken = req.csrfToken();
  next();
});

/* --------------------------
 * Static locals
 * --------------------------------------- */
app.locals = {
  title: app.settings.title,
  version: app.settings.version,
  environment: app.settings.environment,
{'fraction_non_alphanumeric': 0.2524177949709865, 'fraction_numerical': 0.006769825918762089, 'mean_word_length': 2.6162587412587412, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2450644', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1239, 'n_words': 244}