<commit_before>'use strict';

var Hapi = require('hapi');
var nconf = require('nconf');
var SocketIO = require('socket.io');
var crypto = require('crypto');

var services = require('./lib/services');

nconf.argv().env().file({ file: 'local.json' });

var users = 0;

var options = {
  views: {
    engines: {
      jade: require('jade')
    },
    isCached: process.env.node === 'production',
    path: __dirname + '/views',
    compileOptions: {
      pretty: true
    }
  }
};

var server = Hapi.createServer(nconf.get('domain'), nconf.get('port'), options);

server.pack.register(require('hapi-auth-cookie'), function (err) {

  if(err){
    console.error('Auth blowin\' up y\'all');
  }

  server.auth.strategy('session', 'cookie', {
    password: '<PASSWORD>',
    redirectOnTry: false,
  });

  var routes = [
    {
      method: 'GET',
      path: '/',
      config: {
        handler: home,
        auth: 'session'
      }
    }
  ];

  server.route(routes);

  server.route({
    path: '/{path*}',
    method: "GET",
    config: {
      handler: {
        directory: {
          path: './dist',
          listing: false,
          index: false
        }
      },
      auth: 'session'
    }
  });

  server.start(function () {
    var io = SocketIO.listen(server.listener);

    var getUserId = function (fingerprint, ip) {
      return crypto.createHash('md5').update(fingerprint + ip).digest('hex');
    };

    io.on('connection', function (socket) {
      users ++;

      socket.on('disconnect', function () {
        users --;
        if (users < 0) {
          users = 0;
        }

        io.emit('active', users);
      });

      io.emit('active', users);

      services.recent(function (err, chats) {
        chats.forEach(function (chat) {
          setImmediate(function () {
            socket.emit('message', chat.value);
          });<commit_msg>change route configuration to use 'try' instead of straight 'session'.<commit_after>'use strict';

var Hapi = require('hapi');
var nconf = require('nconf');
var SocketIO = require('socket.io');
var crypto = require('crypto');

var services = require('./lib/services');

nconf.argv().env().file({ file: 'local.json' });

var users = 0;

var options = {
  views: {
    engines: {
      jade: require('jade')
    },
    isCached: process.env.node === 'production',
    path: __dirname + '/views',
    compileOptions: {
      pretty: true
    }
  }
};

var server = Hapi.createServer(nconf.get('domain'), nconf.get('port'), options);

server.pack.register(require('hapi-auth-cookie'), function (err) {

  if(err){
    console.error('Auth blowin\' up y\'all');
  }

  server.auth.strategy('session', 'cookie', {
    password: '<PASSWORD>'
  });

  var routes = [
    {
      method: 'GET',
      path: '/',
      config: {
        handler: home,
        auth: {
          strategy: 'session',
          mode: 'try'
        }
      }
    }
  ];

  server.route(routes);

  server.route({
    path: '/{path*}',
    method: "GET",
    config: {
      handler: {
        directory: {
          path: './dist',
          listing: false,
          index: false
        }
      },
      auth: {
        strategy: 'session',
        mode: 'try'
      }
    }
  });

  server.start(function () {
    var io = SocketIO.listen(server.listener);

    var getUserId = function (fingerprint, ip) {
      return crypto.createHash('md5').update(fingerprint + ip).digest('hex');
    };

    io.on('connection', function (socket) {
      users ++;

      socket.on('disconnect', function () {
        users --;
        if (users < 0) {
          users = 0;
        }

        io.emit('active', users);
      });

      io.emit('active', users);

      services.recent(function (err, chats) {
        chats.forEach(function (chat) {
          setImmediate(function () {
            socket.emit('message', chat.value);
          });
{'fraction_non_alphanumeric': 0.17422680412371133, 'fraction_numerical': 0.002061855670103093, 'mean_word_length': 2.183757178014766, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2285916', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1222, 'n_words': 253}