<commit_before>/**
 * Serves static assets and proxies /_api requests to couchdb
 */

var Hapi = require('hapi');

module.exports = function () {

  return function (env_config, callback) {

    var server = new Hapi.Server();

    env_config.hooks.runStatic('server.pack.pre', [server]);

    server.connection({
      port: env_config.www_port,
      labels: ['web'],
      routes: {
        cors: {
          override: false
        },
        payload: {
          maxBytes: 1048576 * 10 // 10 MB
        }
      }
    });

    server.connection({
      port: env_config.admin_port,
      labels: ['admin'],
      routes: {
        cors: {
          override: false
        },
        payload: {
          maxBytes: 1048576 * 10 // 10 MB
        }
      }
    });

    var hapi_plugins = [
      './plugins/web',
      './plugins/admin',
      './plugins/api',
      './helpers/logger',
      './helpers/handle_404'
    ];

    // register plugins against the server pack
    //
    hapi_plugins.forEach(function (plugin) {
      server.register({
        register: require(plugin),
        options: {
          app: env_config
        }
      }, function (err) {
        if (err) {
          console.error('Failed to load a plugin:', err);
        }
      });
    });

    env_config.hooks.runStatic('server.pack.post', [server]);

    server.start(function () {
      console.log('WWW:   ', env_config.www_link());
      console.log('Admin: ', env_config.admin_link());

      return callback();
    });

  };

};

<commit_msg>refactor(server): consolidate connection configuration<commit_after>/**
 * Serves static assets and proxies /_api requests to couchdb
 */

var Hapi = require('hapi');

module.exports = function () {

  return function (env_config, callback) {

    var server = new Hapi.Server({
      connections: {
        routes: {
          cors: {
            override: false
          },
          payload: {
            maxBytes: 1048576 * 10 // 10 MB
          }
        }
      }
    });

    env_config.hooks.runStatic('server.pack.pre', [server]);

    server.connection({
      port: env_config.www_port,
      labels: ['web']
    });

    server.connection({
      port: env_config.admin_port,
      labels: ['admin']
    });

    var hapi_plugins = [
      './plugins/web',
      './plugins/admin',
      './plugins/api',
      './helpers/logger',
      './helpers/handle_404'
    ];

    // register plugins against the server pack
    //
    hapi_plugins.forEach(function (plugin) {
      server.register({
        register: require(plugin),
        options: {
          app: env_config
        }
      }, function (err) {
        if (err) {
          console.error('Failed to load a plugin:', err);
        }
      });
    });

    env_config.hooks.runStatic('server.pack.post', [server]);

    server.start(function () {
      console.log('WWW:   ', env_config.www_link());
      console.log('Admin: ', env_config.admin_link());

      return callback();
    });

  };

};


{'fraction_non_alphanumeric': 0.14798802793481874, 'fraction_numerical': 0.012969737279680744, 'mean_word_length': 1.8431001890359169, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '2314721', 'n_tokens_mistral': 944, 'n_tokens_neox': 908, 'n_words': 184}