<commit_before>#!/usr/bin/env node

/**
 * DaTtSs: dattss.js Server configuration
 *
 * (c) Copyright Teleportd Labs 2013. All Rights reserved
 *
 * @author: n1t0
 *
 * @log:
 * 2013-04-22  n1t0    Add aggregation routes
 * 2013-04-15  n1t0    Creation
 */

/**
 * Module dependencies.
 */
var util = require('util');
var express = require('express');
var http = require('http');
var cookie = require('cookie');
var cookie_signature = require('cookie-signature');

var app = express();

var factory = require('./factory.js').factory;

var setup = function() {
  /* Configuration */
  app.configure(function(){
    app.use(express.cookieParser());
    app.use('/s', express.session({
      secret: factory.config()['DATTSS_SECRET'],
      store: factory.session_store(),
      key: 'dattss.sid',
      cookie: {
        maxAge: factory.config()['DATTSS_COOKIE_AGE']
      }
    }));
    app.use('/demo', function(req, res, next) {
      req.is_demo = true;
      return express.static(__dirname + '/app')(req, res, next);
    });
    app.use('/', express.static(__dirname + '/app'));
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(factory.access().verify);
    app.use(app.router);
    app.use(factory.access().error);
  });

  /* Routes */

  /* AUTH */
  app.get( '/s/auth/user',                         require('./routes/auth.js').get_user);
  app.get( '/s/auth/user',                         require('./routes/auth.js').get_user);
  app.post('/s/auth/signup',                       require('./routes/auth.js').post_signup);
  app.post('/s/auth/signin',                       require('./routes/auth.js').post_signin);
  app.post('/s/auth/password',                     require('./routes/auth.js').post_password);
  app.post('/s/auth/reset',                        require('./routes/auth.js').post_reset);
  app.get( '/s/auth/signout',                      require('./routes/auth.js').get_signout);

  /* ENGINE */
  app.put( '/agg',                                 require('./routes/engine.js').put_agg);
  app.put( '/process',                             require('./routes/engine.js').put_process);

  app.get( '/s/status',                            require('./routes/engine.js').get_status);
  app.get( '/s/processes',                         require('./routes/engine.js').get_processes);
  app.del( '/s/process/:name',                     require('./routes/engine.js').del_process);
  app.get( '/s/stats/:path/:type/:offset/:step',   require('./routes/engine.js').get_stats);

  app.get( '/s/favorite',                          require('./routes/engine.js').get_favorite);
  app.put( '/s/favorite/:favorite',                require('./routes/engine.js').put_favorite);
  app.del( '/s/favorite/:favorite',                require('./routes/engine.js').del_favorite);

  /* ALERTS */
  app.get( '/s/alert',                             require('./routes/alerts.js').get_alerts);
  app.put( '/s/alert/:type/:path',                 require('./routes/alerts.js').put_alert);
  app.del( '/s/alert/:aid',                        require('./routes/alerts.js').del_alert);
};

var setup_io = function(io) {
  if(!factory.config()['DEBUG'])
    io.set('log level', 1);
  else
    io.set('log level', 3);

  var io_main = io.of('/s');
  var io_demo = io.of('/demo');
<commit_msg>disable websocket push by default, so that it works in default settings of nginx env<commit_after>#!/usr/bin/env node

/**
 * DaTtSs: dattss.js Server configuration
 *
 * (c) Copyright Teleportd Labs 2013. All Rights reserved
 *
 * @author: n1t0
 *
 * @log:
 * 2013-04-22  n1t0    Add aggregation routes
 * 2013-04-15  n1t0    Creation
 */

/**
 * Module dependencies.
 */
var util = require('util');
var express = require('express');
var http = require('http');
var cookie = require('cookie');
var cookie_signature = require('cookie-signature');

var app = express();

var factory = require('./factory.js').factory;

var setup = function() {
  /* Configuration */
  app.configure(function(){
    app.use(express.cookieParser());
    app.use('/s', express.session({
      secret: factory.config()['DATTSS_SECRET'],
      store: factory.session_store(),
      key: 'dattss.sid',
      cookie: {
        maxAge: factory.config()['DATTSS_COOKIE_AGE']
      }
    }));
    app.use('/demo', function(req, res, next) {
      req.is_demo = true;
      return express.static(__dirname + '/app')(req, res, next);
    });
    app.use('/', express.static(__dirname + '/app'));
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(factory.access().verify);
    app.use(app.router);
    app.use(factory.access().error);
  });

  /* Routes */

  /* AUTH */
  app.get( '/s/auth/user',                         require('./routes/auth.js').get_user);
  app.get( '/s/auth/user',                         require('./routes/auth.js').get_user);
  app.post('/s/auth/signup',                       require('./routes/auth.js').post_signup);
  app.post('/s/auth/signin',                       require('./routes/auth.js').post_signin);
  app.post('/s/auth/password',                     require('./routes/auth.js').post_password);
  app.post('/s/auth/reset',                        require('./routes/auth.js').post_reset);
  app.get( '/s/auth/signout',                      require('./routes/auth.js').get_signout);

  /* ENGINE */
  app.put( '/agg',                                 require('./routes/engine.js').put_agg);
  app.put( '/process',                             require('./routes/engine.js').put_process);

  app.get( '/s/status',                            require('./routes/engine.js').get_status);
  app.get( '/s/processes',                         require('./routes/engine.js').get_processes);
  app.del( '/s/process/:name',                     require('./routes/engine.js').del_process);
  app.get( '/s/stats/:path/:type/:offset/:step',   require('./routes/engine.js').get_stats);

  app.get( '/s/favorite',                          require('./routes/engine.js').get_favorite);
  app.put( '/s/favorite/:favorite',                require('./routes/engine.js').put_favorite);
  app.del( '/s/favorite/:favorite',                require('./routes/engine.js').del_favorite);

  /* ALERTS */
  app.get( '/s/alert',                             require('./routes/alerts.js').get_alerts);
  app.put( '/s/alert/:type/:path',                 require('./routes/alerts.js').put_alert);
  app.del( '/s/alert/:aid',                        require('./routes/alerts.js').del_alert);
};

var setup_io = function(io) {
  if(!factory.config()['DEBUG'])
    io.set('log level', 1);
  else
    io.set('log level', 3);

  var io_main = io.of('/s');
  var io_demo = io.of('/demo');

  // FIXME: uncommment below line so that web-socket is used for pushing.
  //
  io.set('transports', ['xhr-polling', 'htmlfile', 'jsonp-polling']);

{'fraction_non_alphanumeric': 0.1971933927788335, 'fraction_numerical': 0.00818593772840228, 'mean_word_length': 2.2001870907390084, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3693521', 'n_tokens_mistral': 2196, 'n_tokens_neox': 2168, 'n_words': 345}