<commit_before>'use strict';

var express        = require('express');
var logger         = require('morgan');
var path           = require('path');
var responseTime   = require('response-time');
var methodOverride = require('method-override');
var multer         = require('multer');
var compression    = require('compression');
var cors           = require('cors');
var favicon        = require('serve-favicon');
var bodyParser     = require('body-parser');
var cookieParser   = require('cookie-parser');
var session        = require('express-session');
var RedisStore     = require('connect-redis')(session);
var errorHandler   = require('errorhandler');
var flash          = require('express-flash');
var _              = require('lodash');

var _app = null;
var _server = null;

function _configure() {
	var env   = _app.config.get('server.env');
	var root  = _app.root;
	var paths = _app.config.get('paths');

	_server
		.set('views', path.join(_app.root, paths.server, 'templates'))
		.set('view engine', 'jade')
		.enable('trust proxy')
		.disable('x-powered-by');

	// Express middleware
	_server
		.use(favicon(path.join(_app.root, paths.public, 'favicon.png')))
		.use(bodyParser.json())
		.use(bodyParser.urlencoded({
			extended: true
		}))
		// .use(multer())
		.use(methodOverride());

	if (_app.config.get('server.allowCrossDomain')) {
		_server.use(cors());
	}

	_server.use(cookieParser(_app.config.get('app.secret')));
	_server.use(session({
		secret: _app.config.get('app.secret'),
		saveUninitialized: true,
		resave: true,
		store: new RedisStore()
	}));

	_server.use(_app.passport.initialize());
	_server.use(_app.passport.session({
		maxAge: new Date(Date.now() + 86400000)
	}));

	_server.use(express.static(path.join(_app.root, paths.dist)));
	_server.use(function (req, res, next) {
		res.locals.NODE_ENV        = env;
		res.locals.auth            = {};
		res.locals.auth.local      = _app.config.get('auth.local.enabled');
		res.locals.auth.twitter    = _app.config.get('auth.twitter.enabled');
		res.locals.auth.facebook   = _app.config.get('auth.facebook.enabled');
		res.locals.auth.google     = _app.config.get('auth.google.enabled');
		res.locals.app             = {};
		res.locals.app.name        = _app.config.get('app.name');
		res.locals.app.keywords    = _app.config.get('app.keywords');
		res.locals.app.description = _app.config.get('app.description');

		if(_.isObject(req.user)) {
			res.locals.User = req.user;
		}
		next();
	});

	/*
	 * res.cRender() searches for the template in the component templates directory
	 * it requires the syntax res.cRender('component/view', locals, cb);
	 */
	_server.use(function(req, res, next) {
		res.cRender = function(view, locals, cb) {
			var viewArr = view.split('/');
			var tpl = path.join(_app.root, paths.server, 'components', viewArr[0], 'templates', viewArr[1]); 
			return res.render(tpl, locals, cb);<commit_msg>fixed indent<commit_after>'use strict';

var express        = require('express');
var logger         = require('morgan');
var path           = require('path');
var responseTime   = require('response-time');
var methodOverride = require('method-override');
var multer         = require('multer');
var compression    = require('compression');
var cors           = require('cors');
var favicon        = require('serve-favicon');
var bodyParser     = require('body-parser');
var cookieParser   = require('cookie-parser');
var session        = require('express-session');
var RedisStore     = require('connect-redis')(session);
var errorHandler   = require('errorhandler');
var flash          = require('express-flash');
var _              = require('lodash');

var _app = null;
var _server = null;

function _configure() {
	var env   = _app.config.get('server.env');
	var root  = _app.root;
	var paths = _app.config.get('paths');

	_server
		.set('views', path.join(_app.root, paths.server, 'templates'))
		.set('view engine', 'jade')
		.enable('trust proxy')
		.disable('x-powered-by');

	// Express middleware
	_server
		.use(favicon(path.join(_app.root, paths.public, 'favicon.png')))
		.use(bodyParser.json())
		.use(bodyParser.urlencoded({
			extended: true
		}))
		// .use(multer())
		.use(methodOverride());

	if (_app.config.get('server.allowCrossDomain')) {
		_server.use(cors());
	}

	_server.use(cookieParser(_app.config.get('app.secret')));
	_server.use(session({
		secret: _app.config.get('app.secret'),
		saveUninitialized: true,
		resave: true,
		store: new RedisStore()
	}));

	_server.use(_app.passport.initialize());
	_server.use(_app.passport.session({
		maxAge: new Date(Date.now() + 86400000)
	}));

	_server.use(express.static(path.join(_app.root, paths.dist)));
	_server.use(function (req, res, next) {
		res.locals.NODE_ENV        = env;
		res.locals.auth            = {};
		res.locals.auth.local      = _app.config.get('auth.local.enabled');
		res.locals.auth.twitter    = _app.config.get('auth.twitter.enabled');
		res.locals.auth.facebook   = _app.config.get('auth.facebook.enabled');
		res.locals.auth.google     = _app.config.get('auth.google.enabled');
		res.locals.app             = {};
		res.locals.app.name        = _app.config.get('app.name');
		res.locals.app.keywords    = _app.config.get('app.keywords');
		res.locals.app.description = _app.config.get('app.description');

		if(_.isObject(req.user)) {
			res.locals.User = req.user;
		}
		next();
	});

	/*
	* res.cRender() searches for the template in the component templates directory
	* it requires the syntax res.cRender('component/view', locals, cb);
	*/
	_server.use(function(req, res, next) {
		res.cRender = function(view, locals, cb) {
			var viewArr = view.split('/');
			var tpl = path.join(_app.root, paths.server, 'components', viewArr[0], 'templates', viewArr[1]);
			return res.render(tpl, locals, cb);
{'fraction_non_alphanumeric': 0.17502153316106805, 'fraction_numerical': 0.0034453057708871662, 'mean_word_length': 3.615262321144674, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7351980', 'n_tokens_mistral': 2051, 'n_tokens_neox': 1923, 'n_words': 352}