<commit_before>/* global __dirname, app */

/**
 * Server.js
 */
const http = require('http');
const express = require('express');
const socketio = require('socket.io');
const _ = require('underscore');
const nunjucks = require('nunjucks');
const ejs = require('ejs');
const path = require('path');
const morgan = require('morgan');
const bodyParser = require('body-parser');
const compression = require('compression');
const multer = require('multer');
const helmet = require('helmet');
const responses = require('./responses');

// Include all api controllers
const AllControllers = require('include-all')({
  dirname: path.normalize(path.join(__dirname, '../app/controllers')),
  filter: /(.+Controller)\.js$/,
  optional: true
});

module.exports = {

  port: 5000,

  routes: {},

  start: function (cb) {

    const jwtMiddleware = require('../app/services/Jwt');
    const cors = app.config.cors || {};
    const jwt = app.config.jwt || {};
    const views = app.server.views || {};
    const port = process.env.PORT || parseInt(app.server.port) || 5000;
    const sockets = app.server.sockets || {};

    // Middleware
    const middleware = app.config.middleware || function (req, res, next) {
      next();
    };

    // Uploader
    const upload = multer({dest: app.server.uploadPath});

    const server = express();

    // Settings
    server.use(morgan('dev', {
      skip: function (req, res) {
        return res.statusCode < 400;
      }
    }));
    server.use(compression());
    server.use(bodyParser.json());
    server.use(bodyParser.urlencoded({extended: true}));
    server.use(helmet());
    server.use(responses);
    server.use(express.static(`${process.cwd()}/public`));
    server.options('*', function (req, res) {
<commit_msg>[Added] Support for trust proxy<commit_after>/* global __dirname, app */

/**
 * Server.js
 */
const http = require('http');
const express = require('express');
const socketio = require('socket.io');
const _ = require('underscore');
const nunjucks = require('nunjucks');
const ejs = require('ejs');
const path = require('path');
const morgan = require('morgan');
const bodyParser = require('body-parser');
const compression = require('compression');
const multer = require('multer');
const helmet = require('helmet');
const responses = require('./responses');

// Include all api controllers
const AllControllers = require('include-all')({
  dirname: path.normalize(path.join(__dirname, '../app/controllers')),
  filter: /(.+Controller)\.js$/,
  optional: true
});

module.exports = {

  port: 5000,

  routes: {},

  start: function (cb) {

    const jwtMiddleware = require('../app/services/Jwt');
    const cors = app.config.cors || {};
    const jwt = app.config.jwt || {};
    const views = app.server.views || {};
    const port = process.env.PORT || parseInt(app.server.port) || 5000;
    const sockets = app.server.sockets || {};

    // Middleware
    const middleware = app.config.middleware || function (req, res, next) {
      next();
    };

    // Uploader
    const upload = multer({dest: app.server.uploadPath});

    const server = express();

    // Settings
    server.enable('trust proxy');
    server.use(morgan('dev', {
      skip: function (req, res) {
        return res.statusCode < 400;
      }
    }));
    server.use(compression());
    server.use(bodyParser.json());
    server.use(bodyParser.urlencoded({extended: true}));
    server.use(helmet());
    server.use(responses);
    server.use(express.static(`${process.cwd()}/public`));
    server.use((req, res, next) => {
      let proto = req.connection.encrypted ? 'https' : 'http';
      req.protocol = (req.headers['x-forwarded-proto'] || proto).split(/\s*,\s*/)[0];
      next();
    });
    server.options('*', function (req, res) {

{'fraction_non_alphanumeric': 0.18395976707252515, 'fraction_numerical': 0.006087877183695077, 'mean_word_length': 3.5420673076923075, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '2430848', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1160, 'n_words': 260}