<commit_before>//
// Letschatbro Server
//

var _ = require('underscore');

var fs = require('fs');
var express = require('express');
var expressNamespace = require('express-namespace');
var mongoose = require('mongoose');
var MongoStore = require('connect-mongo')(express);
var swig = require('swig');
var hash = require('node_hash');

// App stuff
var formValidators = require('./formValidators.js')
var ChatServer = require('./chatServer.js');

// Models
var User = require('./models/user.js');
var File = require('./models/file.js');

// TODO: We should require login on all routes
var requireLogin = function (req, res, next) {
    if (req.session.user) {
        next();
    } else {
        res.redirect('/login?next=' + req.path);
    }
};

var Server = function (config) {

    var self = this;

    self.config = config;

	// Setup server
	self.app = express.createServer();

	// Setup session store
	self.sessionStore = new MongoStore({
		host: self.config.db_host,
		db: self.config.db_name
    });

	// Configuration
	self.app.configure(function () {

		// Setup template stuffs
		self.app.register('.html', swig);
		self.app.set('view engine', 'html');
		swig.init({
			cache: false,
			root: 'views',
			allowErrors: true // allows errors to be thrown and caught by express
		});
		self.app.set('views', 'views');
		self.app.set('view options', {
			layout: false // Prevents express from fucking up our extend/block tags
		});

		self.app.use(express.bodyParser());
		self.app.use(express.cookieParser());
		self.app.use(express.session({
			key: 'express.sid',
			cookie: {
				httpOnly: false // We have to turn off httpOnly for websockets
			}, 
			secret: self.config.cookie_secret,
			store: self.sessionStore
		}));

		// Static directory
		self.app.use('/media', express.static('media'));

		self.app.use(self.app.router);
	
	});
<commit_msg>Templating caching is now toggled based on debug value<commit_after>//
// Letschatbro Server
//

var _ = require('underscore');

var fs = require('fs');
var express = require('express');
var expressNamespace = require('express-namespace');
var mongoose = require('mongoose');
var MongoStore = require('connect-mongo')(express);
var swig = require('swig');
var hash = require('node_hash');

// App stuff
var formValidators = require('./formValidators.js')
var ChatServer = require('./chatServer.js');

// Models
var User = require('./models/user.js');
var File = require('./models/file.js');

// TODO: We should require login on all routes
var requireLogin = function (req, res, next) {
    if (req.session.user) {
        next();
    } else {
        res.redirect('/login?next=' + req.path);
    }
};

var Server = function (config) {

    var self = this;

    self.config = config;

	// Setup server
	self.app = express.createServer();

	// Setup session store
	self.sessionStore = new MongoStore({
		host: self.config.db_host,
		db: self.config.db_name
    });

	// Configuration
	self.app.configure(function () {

		// Setup template stuffs
		self.app.register('.html', swig);
		self.app.set('view engine', 'html');
		swig.init({
			cache: !self.config.debug,
			root: 'views',
			allowErrors: self.config.debug // allows errors to be thrown and caught by express
		});
		self.app.set('views', 'views');
		self.app.set('view options', {
			layout: false // Prevents express from fucking up our extend/block tags
		});

		self.app.use(express.bodyParser());
		self.app.use(express.cookieParser());
		self.app.use(express.session({
			key: 'express.sid',
			cookie: {
				httpOnly: false // We have to turn off httpOnly for websockets
			}, 
			secret: self.config.cookie_secret,
			store: self.sessionStore
		}));

		// Static directory
		self.app.use('/media', express.static('media'));

		self.app.use(self.app.router);
	
	});

{'fraction_non_alphanumeric': 0.16249670792731102, 'fraction_numerical': 0.0, 'mean_word_length': 3.4525205158264947, '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': '3338075', 'n_tokens_mistral': 1290, 'n_tokens_neox': 1183, 'n_words': 306}