<commit_before>import {URL} from 'url'
import * as express from 'express'
import * as morgan from 'morgan'
import * as helmet from 'helmet'
import {createRequestHandler} from '@remix-run/express'

const app = express()

if (process.env.NODE_ENV === 'development') {
  app.use(morgan('dev'))
}

if (process.env.NODE_ENV === 'production') {
  app.use(
    helmet({
      contentSecurityPolicy: {
        directives: {
          defaultSrc: ["'none'"],
          scriptSrc: ["'self'", "https: 'unsafe-inline'"],
          scriptSrcElem: ["'self'", "https: 'unsafe-inline'"],
          imgSrc: ["'self'", 'data:'],
          styleSrc: ["'self'"],
          styleSrcElem: ["'self'"],
        },
      },
      hsts: {
        maxAge: 63072000,
        preload: true,
      },
    })
  )
} else {
  app.use(
    helmet.contentSecurityPolicy({
      directives: {
        defaultSrc: ["'none'"],
        scriptSrc: ["'self'", 'http://localhost:8002'],<commit_msg>Fix CSP error in local dev<commit_after>import {URL} from 'url'
import * as express from 'express'
import * as morgan from 'morgan'
import * as helmet from 'helmet'
import {createRequestHandler} from '@remix-run/express'

const app = express()

if (process.env.NODE_ENV === 'development') {
  app.use(morgan('dev'))
}

if (process.env.NODE_ENV === 'production') {
  app.use(
    helmet({
      contentSecurityPolicy: {
        directives: {
          defaultSrc: ["'none'"],
          scriptSrc: ["'self'", "https: 'unsafe-inline'"],
          scriptSrcElem: ["'self'", "https: 'unsafe-inline'"],
          imgSrc: ["'self'", 'data:'],
          styleSrc: ["'self'"],
          styleSrcElem: ["'self'"],
        },
      },
      hsts: {
        maxAge: 63072000,
        preload: true,
      },
    })
  )
} else {
  app.use(
    helmet.contentSecurityPolicy({
      directives: {
        defaultSrc: ["'none'"],
        scriptSrc: ["'self'", "'unsafe-inline'", 'http://localhost:8002'],
{'fraction_non_alphanumeric': 0.1831275720164609, 'fraction_numerical': 0.012345679012345678, 'mean_word_length': 2.656015037593985, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6385211', 'n_tokens_mistral': 649, 'n_tokens_neox': 636, 'n_words': 141}