<commit_before>var Async = require('async');
var Mongoose = require('mongoose');
var Express = require('express');
var BodyParser = require('body-parser');
var PathToRegexp = require('path-to-regexp');

var SwaggerBuilder = require('./swagger-builder.js');

var MONGO_FIELDS = ['_id', '__v'];
var SELECT = MONGO_FIELDS.map(function(f) {return '-' + f}).join(' ');

var removeMongoFields = function(obj) {
  if (typeof obj !== 'object') return obj;
  else if (Array.isArray(obj)) return obj.map(removeMongoFields);
  else {
    for (key in obj) {
      if (MONGO_FIELDS.indexOf(key) === -1) {
        obj[key] = removeMongoFields(obj[key]);
      } else {
        delete obj[key];
      }
    }
    return obj;
  }
}

var setJamminDefaults = function(req, res, next) {
  req.jammin = {
    query: req.query,
    document: req.body,
    method: req.method.toLowerCase(),
  }
  next();
}

/** API **/

var API = function(options) {
  if (typeof options === 'string') options =  {databaseURL: options};
  this.router = Express.Router();<commit_msg>Copy body instead of referencing<commit_after>var Async = require('async');
var Mongoose = require('mongoose');
var Express = require('express');
var BodyParser = require('body-parser');
var PathToRegexp = require('path-to-regexp');

var SwaggerBuilder = require('./swagger-builder.js');

var MONGO_FIELDS = ['_id', '__v'];
var SELECT = MONGO_FIELDS.map(function(f) {return '-' + f}).join(' ');

var removeMongoFields = function(obj) {
  if (typeof obj !== 'object') return obj;
  else if (Array.isArray(obj)) return obj.map(removeMongoFields);
  else {
    for (key in obj) {
      if (MONGO_FIELDS.indexOf(key) === -1) {
        obj[key] = removeMongoFields(obj[key]);
      } else {
        delete obj[key];
      }
    }
    return obj;
  }
}

var setJamminDefaults = function(req, res, next) {
  req.jammin = {
    query: req.query,
    document: JSON.parse(JSON.stringify(req.body)),
    method: req.method.toLowerCase(),
  }
  next();
}

/** API **/

var API = function(options) {
  if (typeof options === 'string') options =  {databaseURL: options};
  this.router = Express.Router();
{'fraction_non_alphanumeric': 0.17142857142857143, 'fraction_numerical': 0.000936768149882904, 'mean_word_length': 3.673960612691466, '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': '1393117', 'n_tokens_mistral': 730, 'n_tokens_neox': 722, 'n_words': 167}