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

const Hapi = require('@hapi/hapi');
const inert = require('@hapi/inert');
const HapiBpc = require('hapi-bpc');
const backend = require('./backend');
const nyhedsbreve = require('./nyhedsbreve');
const smartlinks = require('./smartlinks');
const opdatering = require('./opdatering');
const mineData = require('./mine-data');
// const hapiAuthJwt2 = require('hapi-auth-jwt2');
// const { authConfig } = require('./lib/jwt');

const init = async () => {

  const server = Hapi.server({
      port: 3000,
      host: 'localhost'
  });


  // await server.register(hapiAuthJwt2);
  // server.auth.strategy('jwt', 'jwt',
  // { key: process.env.JWT_SECRET, // Never Share your secret key
    // validate: authConfig.validateFunc  // validate function defined above
  // });

  // server.auth.default('jwt');

  // server.auth.strategy('jwt', 'jwt', authConfig);

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


  await server.register(inert);
  
  // 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;
  }
  console.log(`Using ${ process.env.BPC_APP_ID }`)
  console.log(`Using ${ process.env.BPC_APP_KEY }`)
  await server.register(HapiBpc);
  await server.bpc.connect();

  await server.register(nyhedsbreve);
  await server.register(opdatering, {routes: {prefix: '/opdatering'}});
  await server.register(backend, {routes: {prefix: '/backend'}});
  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();

// var server = new Hapi.Server({
//   connections: {
//     router: {
//       stripTrailingSlash: false
//     }
//   }
// });



// server.connection({
//   port: process.env.PORT ? process.env.PORT : 8000,
//   routes: {
//     cors: true
//   }
// });

// server.register(hapiAuthJwt2, err => {
//   if (err) {
//     console.log(err);
//   }



//   if (!module.parent) {
//     server.start((err) => {
//       if (err) {
//         throw err;
//       }

//       console.log(`Server running at: ${server.info.uri}`);
//     });
//   }
// });

// function cb (err) {
//   if (err) {
//     console.log('Error when loading plugin', err);
//     server.stop();
//   }
// }

// module.exports = server;
<commit_msg>To remain compatible with the puppet-scripts<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 backend = require('./backend');
const nyhedsbreve = require('./nyhedsbreve');
const smartlinks = require('./smartlinks');
const opdatering = require('./opdatering');
const mineData = require('./mine-data');
// const hapiAuthJwt2 = require('hapi-auth-jwt2');
// const { authConfig } = require('./lib/jwt');

const init = async () => {

  const server = Hapi.server({
      port: 3000,
      host: 'localhost'
  });


  // await server.register(hapiAuthJwt2);
  // server.auth.strategy('jwt', 'jwt',
  // { key: process.env.JWT_SECRET, // Never Share your secret key
    // validate: authConfig.validateFunc  // validate function defined above
  // });

  // server.auth.default('jwt');

  // server.auth.strategy('jwt', 'jwt', authConfig);

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


  await server.register(inert);
  
  await server.register(HapiBpc);
  await server.bpc.connect();

  await server.register(nyhedsbreve);
  await server.register(opdatering, {routes: {prefix: '/opdatering'}});
  await server.register(backend, {routes: {prefix: '/backend'}});
  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();

// var server = new Hapi.Server({
//   connections: {
//     router: {
//       stripTrailingSlash: false
//     }
//   }
// });



// server.connection({
//   port: process.env.PORT ? process.env.PORT : 8000,
//   routes: {
//     cors: true
//   }
// });

// server.register(hapiAuthJwt2, err => {
//   if (err) {
//     console.log(err);
//   }



//   if (!module.parent) {
//     server.start((err) => {
//       if (err) {
//         throw err;
//       }

//       console.log(`Server running at: ${server.info.uri}`);
//     });
//   }
// });

// function cb (err) {
//   if (err) {
//     console.log('Error when loading plugin', err);
//     server.stop();
//   }
// }

// module.exports = server;

{'fraction_non_alphanumeric': 0.19169390501826572, 'fraction_numerical': 0.004614497212074601, 'mean_word_length': 2.952887537993921, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '6224901', 'n_tokens_mistral': 1845, 'n_tokens_neox': 1839, 'n_words': 349}