<commit_before>// Check app webserver with SSR for the <head> section


import util from 'util';
import fetch from 'node-fetch';
import window from 'node-window';
import express from 'express';
import serveStatic from 'serve-static';

import configs from '../config-server';
import template from '../src/web/views/index';

const app = express();
const port = process.env.SERVER_PORT || 8000;
const mode = process.env.MODE || 'default';
const config = configs[mode] || configs.default;

// standard headers
app.use((req, res, next) => {
  // CORS
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');

  // cacheing
  // s-maxage is for cloudflare
  // https://support.cloudflare.com/hc/en-us/articles/202775670-How-Do-I-Tell-CloudFlare-What-to-Cache-
  // cloudflare will cache for 15 minutes
  // browser will cache for 5 minutes
  // so the longest a user can go without getting a fresh item from this webserver is ~20 min (14:59 + 5:00)

  // there is a page rule set at Cloudflare to enforce cacheing index.html which is not a CF default
  // https://support.cloudflare.com/hc/en-us/articles/200172256

  if (process.env.NODE_ENV === 'production') {
    res.header('Cache-Control', 'public, s-maxage=900, max-age=300');
  } else {
    res.header('Cache-Control', 'public, no-cache');
  }

  next();
});

app.get('/js/*.bundle.js', (req, res, next) => {
  req.url = `${req.url}.gz`;
  res.set('Content-Encoding', 'gzip');<commit_msg>Fix Firefox SyntaxError: illegal character on development env<commit_after>// Check app webserver with SSR for the <head> section


import util from 'util';
import fetch from 'node-fetch';
import window from 'node-window';
import express from 'express';
import serveStatic from 'serve-static';

import configs from '../config-server';
import template from '../src/web/views/index';

const app = express();
const port = process.env.SERVER_PORT || 8000;
const mode = process.env.MODE || 'default';
const config = configs[mode] || configs.default;

// standard headers
app.use((req, res, next) => {
  // CORS
  res.header('Access-Control-Allow-Origin', '*');
  res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');

  // cacheing
  // s-maxage is for cloudflare
  // https://support.cloudflare.com/hc/en-us/articles/202775670-How-Do-I-Tell-CloudFlare-What-to-Cache-
  // cloudflare will cache for 15 minutes
  // browser will cache for 5 minutes
  // so the longest a user can go without getting a fresh item from this webserver is ~20 min (14:59 + 5:00)

  // there is a page rule set at Cloudflare to enforce cacheing index.html which is not a CF default
  // https://support.cloudflare.com/hc/en-us/articles/200172256

  if (process.env.NODE_ENV === 'production') {
    res.header('Cache-Control', 'public, s-maxage=900, max-age=300');
  } else {
    res.header('Cache-Control', 'public, no-cache');
  }

  next();
});

app.get('/js/*.bundle.js', (req, res, next) => {
  req.url = `${req.url}.gz`;
  res.set('Content-Encoding', 'gzip');
  res.set('Content-Type', 'text/javascript');
{'fraction_non_alphanumeric': 0.16063492063492063, 'fraction_numerical': 0.025396825396825397, 'mean_word_length': 3.767019667170953, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 4, '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': '1022186', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1001, 'n_words': 292}