<commit_before>require('habitat').load();

/*eslint-disable no-unused-vars*/
var newrelic;
/*eslint-disable no-unused-vars*/
if (process.env.NEW_RELIC_ENABLED === 'true') {
  newrelic = require('newrelic');
} else {
  newrelic = {};
}

var Boom = require('boom');
var Path = require('path');
var Hapi = require('hapi');
var Hoek = require('hoek');
var Joi = require('joi');
var polyfillio = require('polyfill-service');
var PolyfillSet = require('./scripts/PolyfillSet.js');
var exchangeRates = require('./assets/exchange-rates/latest.json');
var routes = require('./routes');
var goodConfig = {
  reporter: require('good-console-logfmt')
};
var currencyFor = require('./lib/currency-for.js');

if (process.env.NPM_CONFIG_PRODUCTION === 'true') {
  goodConfig.events = {
    error: '*',
    request: [
      'signup',
      'stripe',
      'paypal'
    ]
  };
} else {
  goodConfig.events = {
    response: '*',
    log: '*',
    request: [
      'signup',
      'stripe',
      'paypal'
    ]
  };
}

module.exports = function(options) {
  var serverOptions = Hoek.applyToDefaults({
    connections: {
      routes: {
        security: {
          hsts: {
            maxAge: 15768000,
            includeSubDomains: true,
            preload: true
          },
          xframe: process.env.ENABLE_XFRAMEOPTIONS === 'true',
          xss: true,
          noOpen: true,
          noSniff: true
        }
      }
    }
  }, options);

  var server = new Hapi.Server(serverOptions);

  server.connection({
    host: process.env.HOST,
    port: process.env.PORT,
    uri: process.env.APPLICATION_URI
  });

  server.register(require("hapi-auth-bearer-token"), function(err) {});

  server.auth.strategy("stripe", "bearer-access-token", {
    validateFunc: function(token, callback) {
      // this = request
      callback(null, token === process.env.STRIPE_WEBHOOK_SECRET, { token: token });
    }
  });

  server.route([
    {
      method: 'POST',
      path: '/api/signup',
      handler: routes.signup,
      config: {
        payload: {
          maxBytes: 32000,
          allow: 'application/json'
        },
        validate: {
          payload: {
            locale: Joi.string().min(2).max(12).required(),
            email: Joi.string().email().required(),
            country: Joi.string().allow('')<commit_msg>remove old comment<commit_after>require('habitat').load();

/*eslint-disable no-unused-vars*/
var newrelic;
/*eslint-disable no-unused-vars*/
if (process.env.NEW_RELIC_ENABLED === 'true') {
  newrelic = require('newrelic');
} else {
  newrelic = {};
}

var Boom = require('boom');
var Path = require('path');
var Hapi = require('hapi');
var Hoek = require('hoek');
var Joi = require('joi');
var polyfillio = require('polyfill-service');
var PolyfillSet = require('./scripts/PolyfillSet.js');
var exchangeRates = require('./assets/exchange-rates/latest.json');
var routes = require('./routes');
var goodConfig = {
  reporter: require('good-console-logfmt')
};
var currencyFor = require('./lib/currency-for.js');

if (process.env.NPM_CONFIG_PRODUCTION === 'true') {
  goodConfig.events = {
    error: '*',
    request: [
      'signup',
      'stripe',
      'paypal'
    ]
  };
} else {
  goodConfig.events = {
    response: '*',
    log: '*',
    request: [
      'signup',
      'stripe',
      'paypal'
    ]
  };
}

module.exports = function(options) {
  var serverOptions = Hoek.applyToDefaults({
    connections: {
      routes: {
        security: {
          hsts: {
            maxAge: 15768000,
            includeSubDomains: true,
            preload: true
          },
          xframe: process.env.ENABLE_XFRAMEOPTIONS === 'true',
          xss: true,
          noOpen: true,
          noSniff: true
        }
      }
    }
  }, options);

  var server = new Hapi.Server(serverOptions);

  server.connection({
    host: process.env.HOST,
    port: process.env.PORT,
    uri: process.env.APPLICATION_URI
  });

  server.register(require("hapi-auth-bearer-token"), function(err) {});

  server.auth.strategy("stripe", "bearer-access-token", {
    validateFunc: function(token, callback) {
      callback(null, token === process.env.STRIPE_WEBHOOK_SECRET, { token: token });
    }
  });

  server.route([
    {
      method: 'POST',
      path: '/api/signup',
      handler: routes.signup,
      config: {
        payload: {
          maxBytes: 32000,
          allow: 'application/json'
        },
        validate: {
          payload: {
            locale: Joi.string().min(2).max(12).required(),
            email: Joi.string().email().required(),
            country: Joi.string().allow('')
{'fraction_non_alphanumeric': 0.16576615517614005, 'fraction_numerical': 0.006915928247244435, 'mean_word_length': 2.492830188679245, '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': '4752346', 'n_tokens_mistral': 1539, 'n_tokens_neox': 1498, 'n_words': 271}