<commit_before>/**
 * This is the rift
 */
var express = require('express');
//var app = express();

var app = express();

app.configure(function(){
  app.use(express.bodyParser());
});

/**
var MongoClient = require('mongodb').MongoClient;
var db = MongoClient.connect("mongodb://localhost:27017/cloudrim", function(err, db) {
  if(err) {
    console.log("Failed to connect");
    exit();
  }
});
console.log( db );
*/

var Db = require('mongodb').Db;
var Connection = require('mongodb').Connection;
var Server = require('mongodb').Server;
var BSON = require('mongodb').BSON;
var ObjectID = require('mongodb').ObjectID;

host = "127.0.0.1"
port = 27017

var db = new Db('cloudrim', new Server(host, port, {auto_reconnect: true}, {}), { w: -1 });
db.open(function(){});

app.get('/kaiju', function(req, res){
  db.collection( "kaiju" ).find().toArray(function(err, docs) { 
    if(!err){
      var body = JSON.stringify({ data: docs });
      res.setHeader('Content-Type', 'application/json');
      res.setHeader('Content-Length', body.length);
      res.end(body);
    }
  });
});

app.post('/kaiju', function(req, res){
  var kaiju = {
    name: req.body.uuid,
    level: req.body.level
  }
  db.collection( "kaiju" ).insert( kaiju, {w:-1}, function(err, docs){<commit_msg>Updating handler<commit_after>/**
 * This is the rift
 */
var express = require('express');
//var app = express();

var app = express();

app.configure(function(){
  app.use(express.bodyParser());
});

/**
var MongoClient = require('mongodb').MongoClient;
var db = MongoClient.connect("mongodb://localhost:27017/cloudrim", function(err, db) {
  if(err) {
    console.log("Failed to connect");
    exit();
  }
});
console.log( db );
*/

var Db = require('mongodb').Db;
var Connection = require('mongodb').Connection;
var Server = require('mongodb').Server;
var BSON = require('mongodb').BSON;
var ObjectID = require('mongodb').ObjectID;

host = "127.0.0.1"
port = 27017

var db = new Db('cloudrim', new Server(host, port, {auto_reconnect: true}, {}), { w: -1 });
db.open(function(){});

app.get('/kaiju', function(req, res){
  db.collection( "kaiju" ).find().sort({ name: 1 }).limit( 10 ).toArray(function(err, docs) { 
    if(!err){
      var body = JSON.stringify({ data: docs });
      res.setHeader('Content-Type', 'application/json');
      res.setHeader('Content-Length', body.length);
      res.end(body);
    }
  });
});

app.post('/kaiju', function(req, res){
  var kaiju = {
    name: req.body.uuid,
    level: req.body.level
  }
  db.collection( "kaiju" ).insert( kaiju, {w:-1}, function(err, docs){
{'fraction_non_alphanumeric': 0.20696324951644102, 'fraction_numerical': 0.015087040618955513, 'mean_word_length': 4.021359223300971, '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': '6279722', 'n_tokens_mistral': 934, 'n_tokens_neox': 882, 'n_words': 197}