<commit_before>"use strict";

// Load required modules
var express       = require('express');
var debug         = require('debug')('coinbox');
var cookieParser  = require('cookie-parser');
var session       = require('express-session');
var crypto        = require('crypto');
var bodyParser    = require('body-parser');
var models        = require('./models');
var config        = require(__dirname + '/config/security.json');

// Create an Express app
var app = express();

// Specify basic route middleware
app.use(express.static('public'));
app.use(session({
  secret: config.session.secret,
  resave: false,
  saveUninitialized: true
}));
app.use(cookieParser());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

// Handle CSRF token management for all routes
app.use ('/', function (req, res, next) {
  debug(req.path);
  if (req.method === 'POST' || req.method === 'PUT') {
    if(req.get('X-XSRF-TOKEN') == req.session.XSRFToken){
      debug('Token match.')
      next();
    } else {
      debug('Token mismatch.')
      res.send({success: false, error: "XSRF Token mismatch."})
    }
  } else if (req.method === 'GET' && (!req.cookies['XSRF-TOKEN']
      || req.get('X-XSRF-TOKEN') != req.session.XSRFToken)) {
    debug('Get request missing CSRF token. Generating and saving...');
    var csrf = crypto.randomBytes(20).toString('hex');
    res.cookie('XSRF-TOKEN', csrf);
    req.session.XSRFToken = csrf;
    next();
  } else {<commit_msg>Make reference to static asset dir absolute<commit_after>"use strict";

// Load required modules
var express       = require('express');
var debug         = require('debug')('coinbox');
var cookieParser  = require('cookie-parser');
var session       = require('express-session');
var crypto        = require('crypto');
var bodyParser    = require('body-parser');
var models        = require('./models');
var config        = require(__dirname + '/config/security.json');

// Create an Express app
var app = express();

// Specify basic route middleware
app.use(express.static(__dirname + '/public'));
app.use(session({
  secret: config.session.secret,
  resave: false,
  saveUninitialized: true
}));
app.use(cookieParser());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());

// Handle CSRF token management for all routes
app.use ('/', function (req, res, next) {
  debug(req.path);
  if (req.method === 'POST' || req.method === 'PUT') {
    if(req.get('X-XSRF-TOKEN') == req.session.XSRFToken){
      debug('Token match.')
      next();
    } else {
      debug('Token mismatch.')
      res.send({success: false, error: "XSRF Token mismatch."})
    }
  } else if (req.method === 'GET' && (!req.cookies['XSRF-TOKEN']
      || req.get('X-XSRF-TOKEN') != req.session.XSRFToken)) {
    debug('Get request missing CSRF token. Generating and saving...');
    var csrf = crypto.randomBytes(20).toString('hex');
    res.cookie('XSRF-TOKEN', csrf);
    req.session.XSRFToken = csrf;
    next();
  } else {
{'fraction_non_alphanumeric': 0.1792233654165284, 'fraction_numerical': 0.001327580484566877, 'mean_word_length': 3.5255255255255253, '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': '1828519', 'n_tokens_mistral': 942, 'n_tokens_neox': 953, 'n_words': 227}