<commit_before>"use strict";

/**
 * Minimalistic Web Application Framework as Promised
 *
 * @module BlueGate
 */

var connect = require('connect');
var bodyParser = require('body-parser');
var cookieParser = require('cookie-parser');
var compression = require('compression');
var http = require('http');
var Promise = require('bluebird');
var url = require('url');
var retrieveArguments = require('retrieve-arguments');
var forwarded = require('forwarded-for');
var _ = require('lodash');

/**
 * Create a new webserver.
 * @constructor
 */
var BlueGate = function(options) {
  var self = this;

  this._options = _.defaults(options, {
    trustedProxies: ['127.0.0.1'],
    clickjacking: 'deny',
    noMimeSniffing: true,
    log: console.log
  });

  this._app = connect();

  this._app.use(bodyParser.urlencoded({extended: false}));
  this._app.use(bodyParser.json());
  this._app.use(cookieParser());
  this._app.use(compression());

  this._app.use(function(req, res, next) {
    return self.handleRequest(req, res, next);
  });

  this.phases = [
    {name: 'initialize', concurrent: true, error: false, errorStatus: 500},
    {name: 'authentication', concurrent: false, error: false, errorStatus: 401},
    {name: 'authorisation', concurrent: false, error: false, errorStatus: 403},
    {name: 'prevalidation', concurrent: true, error: false, errorStatus: 400},
    {name: 'preprocess', concurrent: false, error: false, errorStatus: 500},
    {name: 'postvalidation', concurrent: true, error: false, errorStatus: 400},
    {name: 'process', concurrent: false, error: false, errorStatus: 500},
    {name: 'postprocess', concurrent: false, error: false, errorStatus: 500},
    {name: '_send', concurrent: false, error: false},
    {name: 'after', concurrent: true, error: false},
    {name: 'error', concurrent: false, error: true, errorStatus: 500},
    {name: '_senderror', concurrent: false, error: true},
    {name: 'aftererror', concurrent: true, error: true}
  ];<commit_msg>Add text and raw body parsers<commit_after>"use strict";

/**
 * Minimalistic Web Application Framework as Promised
 *
 * @module BlueGate
 */

var connect = require('connect');
var bodyParser = require('body-parser');
var cookieParser = require('cookie-parser');
var compression = require('compression');
var http = require('http');
var Promise = require('bluebird');
var url = require('url');
var retrieveArguments = require('retrieve-arguments');
var forwarded = require('forwarded-for');
var _ = require('lodash');

/**
 * Create a new webserver.
 * @constructor
 */
var BlueGate = function(options) {
  var self = this;

  this._options = _.defaults(options, {
    trustedProxies: ['127.0.0.1'],
    clickjacking: 'deny',
    noMimeSniffing: true,
    log: console.log
  });

  this._app = connect();

  this._app.use(bodyParser.urlencoded({extended: false}));
  this._app.use(bodyParser.json());
  this._app.use(bodyParser.text({type: 'text/*'}));
  this._app.use(bodyParser.raw());
  this._app.use(cookieParser());
  this._app.use(compression());

  this._app.use(function(req, res, next) {
    return self.handleRequest(req, res, next);
  });

  this.phases = [
    {name: 'initialize', concurrent: true, error: false, errorStatus: 500},
    {name: 'authentication', concurrent: false, error: false, errorStatus: 401},
    {name: 'authorisation', concurrent: false, error: false, errorStatus: 403},
    {name: 'prevalidation', concurrent: true, error: false, errorStatus: 400},
    {name: 'preprocess', concurrent: false, error: false, errorStatus: 500},
    {name: 'postvalidation', concurrent: true, error: false, errorStatus: 400},
    {name: 'process', concurrent: false, error: false, errorStatus: 500},
    {name: 'postprocess', concurrent: false, error: false, errorStatus: 500},
    {name: '_send', concurrent: false, error: false},
    {name: 'after', concurrent: true, error: false},
    {name: 'error', concurrent: false, error: true, errorStatus: 500},
    {name: '_senderror', concurrent: false, error: true},
    {name: 'aftererror', concurrent: true, error: true}
  ];
{'fraction_non_alphanumeric': 0.1659720519735229, 'fraction_numerical': 0.016180436381466046, 'mean_word_length': 4.779036827195467, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '702986', 'n_tokens_mistral': 1329, 'n_tokens_neox': 1232, 'n_words': 350}