<commit_before>var url = require('url'),
    fs = require('fs');

var connect = require('connect'),
    _ = require('underscore')._;

var AmqpClient = require('./amqp_client');

var configFile = process.env.RABBITHOLE_CONFIG || "/etc/rabbithole.cfg";
var config = JSON.parse(fs.readFileSync(configFile, 'utf8'));

var amqpClient = AmqpClient(config);

var conversionMap = {
  true: true,
  false: false,
  null: null
}

var convertArguments = function(args) {
  var converted = {};

  _.each(args, function(value, key) {
    if (value in conversionMap) {
      converted[key] = conversionMap[value];
    } else if (_.isString(value) && value.match(/^\d+$/)) {
      converted[key] = parseInt(value);
    } else {
      converted[key] = value;
    }
  });

  return converted;
}

var server = module.exports = connect.createServer(
  function(req, res, next) {
    var data = '';
    req.setEncoding('utf8');
    req.on('data', function(chunk) { data += chunk; });
    req.on('end', function() {
      req.body = data;
      next();
    });
  },

  connect.router(function(app) {
    app.get('/health', function(req, res) {
      res.writeHead(200);
      res.end("rabbithole: ok\n");
    });

    app.post('/publish/:exchange/:routingKey', function(req, res) {
      var urlObj = url.parse(req.url, true);
      var options = _.extend({}, convertArguments(urlObj.query));

      console.log(options);

      options.exchange = req.params.exchange;<commit_msg>remove console.log<commit_after>var url = require('url'),
    fs = require('fs');

var connect = require('connect'),
    _ = require('underscore')._;

var AmqpClient = require('./amqp_client');

var configFile = process.env.RABBITHOLE_CONFIG || "/etc/rabbithole.cfg";
var config = JSON.parse(fs.readFileSync(configFile, 'utf8'));

var amqpClient = AmqpClient(config);

var conversionMap = {
  true: true,
  false: false,
  null: null
}

var convertArguments = function(args) {
  var converted = {};

  _.each(args, function(value, key) {
    if (value in conversionMap) {
      converted[key] = conversionMap[value];
    } else if (_.isString(value) && value.match(/^\d+$/)) {
      converted[key] = parseInt(value);
    } else {
      converted[key] = value;
    }
  });

  return converted;
}

var server = module.exports = connect.createServer(
  function(req, res, next) {
    var data = '';
    req.setEncoding('utf8');
    req.on('data', function(chunk) { data += chunk; });
    req.on('end', function() {
      req.body = data;
      next();
    });
  },

  connect.router(function(app) {
    app.get('/health', function(req, res) {
      res.writeHead(200);
      res.end("rabbithole: ok\n");
    });

    app.post('/publish/:exchange/:routingKey', function(req, res) {
      var urlObj = url.parse(req.url, true);
      var options = _.extend({}, convertArguments(urlObj.query));

      options.exchange = req.params.exchange;
{'fraction_non_alphanumeric': 0.17449896337249482, 'fraction_numerical': 0.0034554250172771253, 'mean_word_length': 3.3080357142857144, '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': '461969', 'n_tokens_mistral': 965, 'n_tokens_neox': 954, 'n_words': 191}