<commit_before>require('dotenv').config();
const http = require('http');
const server = http.createServer();
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const { resolve } = require('path');
const chalk = require('chalk');
const passport = require('passport');

if (process.env.NODE_ENV !== 'production') {
  // Logging middleware (dev only)
  const morgan = require('morgan');
  app.use(morgan('dev'));
}

// Set up session middleware
app.use(require('cookie-session')({
  name: 'session',<commit_msg>feat: force redirect to https<commit_after>require('dotenv').config();
const http = require('http');
const server = http.createServer();
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const { resolve } = require('path');
const chalk = require('chalk');
const passport = require('passport');

// Custom Middleware to redirect HTTP to https using request headers appended
// By one of Heroku's AWS ELB instances.
// http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/x-forwarded-headers.html
// Note that this is technically vulnerable to man-in-the-middle attacks
const forceSSL = function (req, res, next) {
  if (req.headers['x-forwarded-proto'] !== 'https') {
    console.log('forcing SSL');
    return res.redirect(['https://', req.get('Host'), req.url].join(''));
  }
  return next();
};

if (process.env.NODE_ENV === 'production') {
  app.use(forceSSL);
}

if (process.env.NODE_ENV !== 'production') {
  // Logging middleware (dev only)
  const morgan = require('morgan');
  app.use(morgan('dev'));
}

// Set up session middleware
app.use(require('cookie-session')({
  name: 'session',
{'fraction_non_alphanumeric': 0.17773892773892774, 'fraction_numerical': 0.0, 'mean_word_length': 5.088652482269503, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '604643', 'n_tokens_mistral': 518, 'n_tokens_neox': 511, 'n_words': 138}