<commit_before>const Hapi = require('hapi')
const config = require('./config')
const routes = require('./routes')
const auth = require('./routes/auth')
const stats = require('./routes/stats')
const classes = require('./routes/classes')
const reports = require('./routes/reports')
const documents = require('./routes/documents')
const notes = require('./routes/notes')
const systems = require('./routes/systems')
const yff = require('./routes/yff')
const logger = require('./lib/logger')

// Create a server with a host and port
const server = Hapi.server({
  port: config.WEB_SERVER_PORT
})

// Add the routes
server.route(auth)
server.route(classes)
server.route(documents)
server.route(notes)
server.route(reports)
server.route(routes)
server.route(stats)
server.route(systems)
server.route(yff)

const yarOptions = {
  storeBlank: false,
  cookieOptions: {
    password: <PASSWORD>.<PASSWORD>,
    isSecure: process.env.NODE_ENV !== 'development',
    isSameSite: 'Lax'
  }
}

const plugins = [
  { plugin: require('hapi-auth-cookie') },
  { plugin: require('vision') },
  { plugin: require('inert') },
  { plugin: require('yar'), options: yarOptions }
]

// Start the server
async function start () {
  await server.register(plugins)

  server.route({
    method: 'GET',
    path: '/public/{param*}',
    handler: {
      directory: {
        path: 'public'
      }
    },
    options: {
      auth: false
    }
  })

  server.views({
    engines: {
      html: require('handlebars')
    },
    relativeTo: __dirname,
    path: 'views',
    layout: true,
    layoutPath: 'views/layouts',
    helpersPath: 'views/helpers',
    partialsPath: 'views/partials'
  })

  server.auth.strategy('session', 'cookie', {
    password: <PASSWORD>.COOKIE_SECRET,
    cookie: 'web-minelev-session',
    redirectTo: `${config.AUTH_SERVICE_URL}/login?origin=${config.ORIGIN_URL}`,
    appendNext: 'nextPath',
    isSecure: process.env.NODE_ENV !== 'development',
    isSameSite: 'Lax'
  })

  server.auth.default('session')

  await server.start()
  logger('info', ['server', 'Server running', server.info.uri])
}

start().catch(error => {
  logger('error', ['server', error])
})
<commit_msg>Updates required for hapi-auth-cookie (patch)<commit_after>const Hapi = require('hapi')
const config = require('./config')
const routes = require('./routes')
const auth = require('./routes/auth')
const stats = require('./routes/stats')
const classes = require('./routes/classes')
const reports = require('./routes/reports')
const documents = require('./routes/documents')
const notes = require('./routes/notes')
const systems = require('./routes/systems')
const yff = require('./routes/yff')
const logger = require('./lib/logger')

// Create a server with a host and port
const server = Hapi.server({
  port: config.WEB_SERVER_PORT
})

// Add the routes
server.route(auth)
server.route(classes)
server.route(documents)
server.route(notes)
server.route(reports)
server.route(routes)
server.route(stats)
server.route(systems)
server.route(yff)

const yarOptions = {
  storeBlank: false,
  cookieOptions: {
    password: <PASSWORD>,
    isSecure: process.env.NODE_ENV !== 'development',
    isSameSite: 'Lax'
  }
}

const plugins = [
  { plugin: require('hapi-auth-cookie') },
  { plugin: require('vision') },
  { plugin: require('inert') },
  { plugin: require('yar'), options: yarOptions }
]

// Start the server
async function start () {
  await server.register(plugins)

  server.route({
    method: 'GET',
    path: '/public/{param*}',
    handler: {
      directory: {
        path: 'public'
      }
    },
    options: {
      auth: false
    }
  })

  server.views({
    engines: {
      html: require('handlebars')
    },
    relativeTo: __dirname,
    path: 'views',
    layout: true,
    layoutPath: 'views/layouts',
    helpersPath: 'views/helpers',
    partialsPath: 'views/partials'
  })

  server.auth.strategy('session', 'cookie', {
    cookie: {
      name: 'web-minelev-leder-session',
      password: <PASSWORD>,
      isSecure: process.env.NODE_ENV !== 'development',
      isSameSite: 'Lax'
    },
    redirectTo: `${config.AUTH_SERVICE_URL}/login?origin=${config.ORIGIN_URL}`,
    appendNext: 'nextPath'
  })

  server.auth.default('session')

  await server.start()
  logger('info', ['server', 'Server running', server.info.uri])
}

start().catch(error => {
  logger('error', ['server', error])
})

{'fraction_non_alphanumeric': 0.17011598817375484, 'fraction_numerical': 0.0, 'mean_word_length': 3.744336569579288, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, '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': '5744591', 'n_tokens_mistral': 1414, 'n_tokens_neox': 1420, 'n_words': 301}