<commit_before>(function(){
    
    module.exports.start = function(app) {
        
        var server = {};
        console.log("Env: " + process.env.NODE_ENV)
        var env = process.env.NODE_ENV;
        var port = process.env.PORT || 8080;
        if (env == "development") {
            console.log("Dev env, start HTTPS server");
            var fs = require('fs');
            var https = require('https');
            var options = {
                key  : fs.readFileSync('./certs/dev.cert.key'),
                cert : fs.readFileSync('./certs/dev.cert.crt')
            };
            server = https.createServer(options, app);
            port = 443;
        } else {
            var http = require('http');
            server = http.createServer(app);
        }

        server.listen(port, process.env.IP || "0.0.0.0", function() {
            var addr = server.address();
            console.log("Server listening at", addr.address + ":" + addr.port);
        });
    
    }

}());
<commit_msg>force https<commit_after>(function(){
    
    var httpsRedirect = function(req, res, next) {
        if (req.headers['x-forwarded-proto'] != 'https') {
            return res.redirect(301, 'https://' + req.headers.host + req.url);
        } else {
            return next();
        }
    };
    
    module.exports.start = function(app) {
        
        var server = {};
        console.log("Env: " + process.env.NODE_ENV)
        var env = process.env.NODE_ENV;
        var port = process.env.PORT || 8080;
        if (env == "development") {
            // start a local https server
            var fs = require('fs');
            var https = require('https');
            var options = {
                key  : fs.readFileSync('./certs/dev.cert.key'),
                cert : fs.readFileSync('./certs/dev.cert.crt')
            };
            server = https.createServer(options, app);
            port = 443;
        } else {
            var http = require('http');
            server = http.createServer(app);
            if (env == "production") {
                // force https on production
                app.use(httpsRedirect);
            }
        }

        server.listen(port, process.env.IP || "0.0.0.0", function() {
            var addr = server.address();
            console.log("Server listening at", addr.address + ":" + addr.port);
        });
    
    }

}());

{'fraction_non_alphanumeric': 0.14626262626262626, 'fraction_numerical': 0.010101010101010102, 'mean_word_length': 1.4109055501460566, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '5070309', 'n_tokens_mistral': 715, 'n_tokens_neox': 672, 'n_words': 139}