<commit_before>#!/usr/bin/env node
'use strict';

var express = require('express');
var io = require('socket.io');
var http = require('http');
var helmet = require('helmet');

var path = require('path');
var util = require('util');
var _ = require('lodash');
var fs = require('fs');

var settings;
try {
    settings = require('./settings');
} catch (e) {
    settings = {};
}

var db = require('./db');
var routes = require('./routes');
var models = require('./models');
var sockets = require('./sockets');

var SwiftCODEConfig = require('./config');

var mongoose = require('mongoose');

var SessionStore = require('session-mongoose')(express);

// Auth libs
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
var flash = require('connect-flash');

var requireHTTPS = function(req, res, next) {
    if (req.headers['x-forwarded-proto'] != 'https') {
        return res.redirect(301, 'https://' + req.get('host') + req.url);
    }
    next();
};

var ensureAuthenticated = function(url, admin) {
    return function(req, res, next) {
        if (!req.isAuthenticated || !req.isAuthenticated()) {
            return res.redirect(url);
        } else if (admin && (!req.user || !req.user.isAdmin)) {
            return res.redirect(url);
        }
        next();
    };
};

var SwiftCODE = function() {
    var self = this;

    /**
     * Listen on the configured port and IP
     */
    self.listen = function() {
        self.server = http.createServer(self.app);

        // Socket.IO server needs to listen in the same block as the HTTP
        // server, or you'll get listen EACCES errors (due to Node's context
        // switching?)
        self.io = io.listen(self.server);
        self.server.listen(self.config.port, self.config.ipaddress);<commit_msg>Fix socket.io><commit_after>#!/usr/bin/env node
'use strict';

var express = require('express');
var io = require('socket.io');
var http = require('http');
var helmet = require('helmet');

var path = require('path');
var util = require('util');
var _ = require('lodash');
var fs = require('fs');

var settings;
try {
    settings = require('./settings');
} catch (e) {
    settings = {};
}

var db = require('./db');
var routes = require('./routes');
var models = require('./models');
var sockets = require('./sockets');

var SwiftCODEConfig = require('./config');

var mongoose = require('mongoose');

var SessionStore = require('session-mongoose')(express);

// Auth libs
var passport = require('passport');
var LocalStrategy = require('passport-local').Strategy;
var flash = require('connect-flash');

var requireHTTPS = function(req, res, next) {
    if (req.headers['x-forwarded-proto'] != 'https') {
        return res.redirect(301, 'https://' + req.get('host') + req.url);
    }
    next();
};

var ensureAuthenticated = function(url, admin) {
    return function(req, res, next) {
        if (!req.isAuthenticated || !req.isAuthenticated()) {
            return res.redirect(url);
        } else if (admin && (!req.user || !req.user.isAdmin)) {
            return res.redirect(url);
        }
        next();
    };
};

var SwiftCODE = function() {
    var self = this;

    /**
     * Listen on the configured port and IP
     */
    self.listen = function() {
        self.server = http.createServer(self.app);

        // Socket.IO server needs to listen in the same block as the HTTP
        // server, or you'll get listen EACCES errors (due to Node's context
        // switching?)
        self.io = io(self.server);
        self.server.listen(self.config.port, self.config.ipaddress);
{'fraction_non_alphanumeric': 0.17064372918978912, 'fraction_numerical': 0.001664816870144284, 'mean_word_length': 3.0873015873015874, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 2, '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': '565592', 'n_tokens_mistral': 1096, 'n_tokens_neox': 1079, 'n_words': 294}