<commit_before>/*jshint node: true */
'use strict';

// To remain compatible with the puppet-scripts
if(process.env.NYHEDSBREVEPROFIL_APP_ID && !process.env.BPC_APP_ID) {
  process.env.BPC_APP_ID = process.env.NYHEDSBREVEPROFIL_APP_ID;
  process.env.BPC_APP_KEY = process.env.NYHEDSBREVEPROFIL_APP_SECRET;
}

const Hapi = require('@hapi/hapi');
const inert = require('@hapi/inert');
const HapiBpc = require('hapi-bpc');
const api = require('./api');
const backend = require('./backend');
const nyhedsbreve = require('./nyhedsbreve');
const smartlinks = require('./smartlinks');
const opdatering = require('./opdatering');
const mineData = require('./mine-data');

const init = async () => {

  const server = Hapi.server({ port: process.env.PORT || 8000 });

  server.route({
    method: 'GET',
    path: '/healthcheck',
    handler: function (request, h) {
      return 'OK';
    }
  });

  await server.register(inert);
  
  await server.register(HapiBpc);
  await server.bpc.connect(null, process.env.BPC_URL);

  await server.register(nyhedsbreve);
  await server.register(api, {routes: {prefix: '/api'}});
  await server.register(backend, {routes: {prefix: '/backend'}});
  await server.register(opdatering, {routes: {prefix: '/opdatering'}});
  await server.register(smartlinks, {routes: {prefix: '/smartlinks'}});
  await server.register(mineData, {routes: {prefix: '/mine-data'}});

  await server.start();
  console.log('Server running on %s', server.info.uri);
};

init();<commit_msg>BMD-3764 x-frame-options header added<commit_after>/*jshint node: true */
'use strict';

// To remain compatible with the puppet-scripts
if(process.env.NYHEDSBREVEPROFIL_APP_ID && !process.env.BPC_APP_ID) {
  process.env.BPC_APP_ID = process.env.NYHEDSBREVEPROFIL_APP_ID;
  process.env.BPC_APP_KEY = process.env.NYHEDSBREVEPROFIL_APP_SECRET;
}

const Hapi = require('@hapi/hapi');
const inert = require('@hapi/inert');
const HapiBpc = require('hapi-bpc');
const api = require('./api');
const backend = require('./backend');
const nyhedsbreve = require('./nyhedsbreve');
const smartlinks = require('./smartlinks');
const opdatering = require('./opdatering');
const mineData = require('./mine-data');

const init = async () => {

  const server = Hapi.server({ port: process.env.PORT || 8000 });

  await server.ext('onPreResponse', function (request, reply) {
    request.response.header('X-Frame-Options', 'DENY');
    return reply.continue;
  })

  server.route({
    method: 'GET',
    path: '/healthcheck',
    handler: function (request, h) {
      return 'OK';
    }
  });

  await server.register(inert);
  await server.register(HapiBpc);
  await server.bpc.connect(null, process.env.BPC_URL);

  await server.register(nyhedsbreve);
  await server.register(api, {routes: {prefix: '/api'}});
  await server.register(backend, {routes: {prefix: '/backend'}});
  await server.register(opdatering, {routes: {prefix: '/opdatering'}});
  await server.register(smartlinks, {routes: {prefix: '/smartlinks'}});
  await server.register(mineData, {routes: {prefix: '/mine-data'}});

  await server.start();
  console.log('Server running on %s', server.info.uri);
};

init();
{'fraction_non_alphanumeric': 0.1739405439595193, 'fraction_numerical': 0.003795066413662239, 'mean_word_length': 4.750909090909091, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6224903', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1116, 'n_words': 223}