<commit_before>var express = require('express');
var router = express.Router();
var http = require('http');
var MongoClient = require('mongodb').MongoClient;

var logic_url_base = "http://ec2-52-17-7-182.eu-west-1.compute.amazonaws.com"
var mongoUser = "onedottwo";
var mongoPassword = "<PASSWORD>";

/* Receive SMS */
router.get('/', function(req, res) {
  
  var msg = {
    to: req.query.to,
    from: req.query.from,
    message: req.query.content,
    msg_id: req.query.msg_id
  };

  // Connect to the db and submit change
  MongoClient.connect("mongodb://" + mongoUser + ":" + mongoPassword
      + "@ds031531.mongolab.com:31531/middleman",
      function (err, db) {
    if (!err) {
      var collection = db.collection('messages');
      var document = {'to': req.query.to, 'from': req.query.from, 'message': req.query.content};
      collection.insert(document, {w: 1}, function (err, result) {
        if (err) {
          console.log("Couldn't send to database");
        }
      });
    } else {
      console.log("ERROR: Couldn't connect to remote mongo");
    }
  });
  
  var options = {
    hostname: logic_url_base,
    port: 5000,
    path: '/logic',
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Content-Length': postData.length
    }
  };

  var logic_req = http.request(options, function(res) {
    console.log("request to LOGIC completed: " + res);
  });
  
  logic_req.on("error", function(e) {
    console.log("error making request to LOGIC: " + e.message);
  });
  
  logic_req.write(msg);
  logic_req.end();

  res.json(msg);
});

module.exports = router;<commit_msg>Fuck me! my fault :(<commit_after>var express = require('express');
var router = express.Router();
var http = require('http');
var MongoClient = require('mongodb').MongoClient;

var logic_url_base = "http://ec2-52-17-7-182.eu-west-1.compute.amazonaws.com";
var mongoUser = "onedottwo";
var mongoPassword = "<PASSWORD>";

/* Receive SMS */
router.get('/', function(req, res) {
  
  var msg = {
    to: req.query.to,
    from: req.query.from,
    message: req.query.content,
    msg_id: req.query.msg_id
  };

  // Connect to the db and submit change
  MongoClient.connect("mongodb://" + mongoUser + ":" + mongoPassword
      + "@ds031531.mongolab.com:31531/middleman",
      function (err, db) {
    if (!err) {
      var collection = db.collection('messages');
      var document = {'to': req.query.to, 'from': req.query.from, 'message': req.query.content};
      collection.insert(document, {w: 1}, function (err, result) {
        if (err) {
          console.log("Couldn't send to database");
        }
      });
    } else {
      console.log("ERROR: Couldn't connect to remote mongo");
    }
  });
  
  var options = {
    hostname: logic_url_base,
    port: 5000,
    path: '/logic',
    method: 'POST',
    headers: {
      'Accept': 'application/json',
      'Content-Type': 'application/json',
      'Content-Length': msg.length
    }
  };

  var logic_req = http.request(options, function(res) {
    console.log("request to LOGIC completed: " + res);
  });
  
  logic_req.on("error", function(e) {
    console.log("error making request to LOGIC: " + e.message);
  });
  
  logic_req.write(msg);
  logic_req.end();

  res.json(msg);
});

module.exports = router;
{'fraction_non_alphanumeric': 0.1692400847714199, 'fraction_numerical': 0.01574326369966697, 'mean_word_length': 2.9711538461538463, 'pattern_counts': {'":': 2, '<': 5, '<?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': '881462', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1113, 'n_words': 243}