<commit_before>/* eslint-disable consistent-return */
import path from 'path';
import compression from 'compression';
import express from 'express';
import favicon from 'serve-favicon';
import winston from 'winston';
import expressWinston from 'express-winston';
import cookieParser from 'cookie-parser';
import { host, port, logLevel, isEnvProduction, ssl } from '../../config/consts';
import createSSR from './SSR/createSSR';

export default function (parameters) {
  const app = express();

  if (isEnvProduction) {
    app.use(compression());
  }
  app.disable('etag');
  app.disable('x-powered-by');
  app.use(cookieParser());
  app.use('/', express.static('public', { etag: false }));
  app.use(favicon(path.join('public', 'favicons', 'icon-48x48.png')));
  app.use((req, res, next) => {
    res.set('X-Frame-Options', 'DENY');
    next();
  });
  if (ssl) {
    app.use((req, res, next) => {
      if (req.headers['x-forwarded-proto'] !== 'https') {
        res.redirect(302, `https://${req.hostname}${req.originalUrl}`);
      } else {
        next();
      }
    });
  }
  app.get('/api/users', (req, res) => {
    res.json({
      records: [
        { id: 2, name: '<NAME>' },
        { id: 1, name: '<NAME>' },
      ],
    });
  });
  if (logLevel) {
    const loggerOptions = {
      level: logLevel,
      transports: [
        new winston.transports.Console({
          json: true,
          colorize: true,
        }),
      ],
    };
    app.use(expressWinston.logger(loggerOptions));
  }

  app.get('*', createSSR(parameters && parameters.chunks()));

  const server = app.listen(port, (err) => {
    if (err) {
      return console.error(err);
    }
    if (host && port) {
      console.info(`Listening at ${host}:${port}`);
    }
  });

  return {
    server,
    app,
  };
}<commit_msg>fix(heroku): fix heroku<commit_after>/* eslint-disable consistent-return */
import path from 'path';
import compression from 'compression';
import express from 'express';
import favicon from 'serve-favicon';
import winston from 'winston';
import expressWinston from 'express-winston';
import cookieParser from 'cookie-parser';
import { host, port, logLevel, isEnvProduction, ssl } from '../../config/consts';
import createSSR from './SSR/createSSR';

export default function (parameters) {
  const app = express();

  if (isEnvProduction) {
    app.use(compression());
  }
  app.disable('etag');
  app.disable('x-powered-by');
  app.use(cookieParser());
  app.use('/', express.static('public', { etag: false }));
  app.use(favicon(path.join('public', 'favicons', 'icon-48x48.png')));
  app.use((req, res, next) => {
    res.set('X-Frame-Options', 'DENY');
    next();
  });
  if (ssl) {
    app.use((req, res, next) => {
      if (req.headers['x-forwarded-proto'] !== 'https') {
        res.redirect(302, `https://${req.hostname}${req.originalUrl}`);
      } else {
        next();
      }
    });
  }
  app.get('/api/users', (req, res) => {
    res.json({
      records: [
        { id: 2, name: '<NAME>' },
        { id: 1, name: '<NAME>' },
      ],
    });
  });
  if (logLevel) {
    const loggerOptions = {
      level: logLevel,
      transports: [
        new winston.transports.Console({
          json: true,
          colorize: true,
        }),
      ],
    };
    app.use(expressWinston.logger(loggerOptions));
  }

  app.get('*', createSSR(parameters && parameters.chunks()));
  console.log('port!!!!!!!!!!!! ', port);
  const server = app.listen(port, (err) => {
    if (err) {
      return console.error(err);
    }
    if (host && port) {
      console.info(`Listening at ${host}:${port}`);
    }
  });

  return {
    server,
    app,
  };
}
{'fraction_non_alphanumeric': 0.19525497682028906, 'fraction_numerical': 0.004908644668666485, 'mean_word_length': 2.8288100208768268, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 15, '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': '7180642', 'n_tokens_mistral': 1254, 'n_tokens_neox': 1222, 'n_words': 260}