<commit_before>'use strict'

var Promise = require('bluebird');
var dao = require('../dao/dao');

// Generic error handler used by all endpoints.
function handleError(res, reason, message, code) {
  console.log("ERROR: " + reason);
  res.status(code || 500).json({"error": message});
}

/**
 * Function to add a new POI on database
 */
this.add = function(req, resp) {
  Promise.resolve()
  dao.insert(req)
  .then(function(doc) {
    resp.status(201);
    resp.json(doc);
  })
  .catch(function(err) {
    resp.status(err.statusCode || 500);
    resp.json({status: err.statusCode || 500, message: err.message});
  });
};

/**
 * Function to get all companies on database
 */
this.get = function(req, resp) {
  Promise.resolve()
  dao.findAll(req)
  .then(function(doc) {
    resp.status(201);
    resp.json(doc);
  })
  .catch(function(err) {
    resp.status(err.statusCode || 500);
    resp.json({status: err.statusCode || 500, message: err.message});
  });
};

/**
 * Function to get all companies on database
 */
this.update = function(req, resp) {
  dao.update(req)
  .then(function(doc) {
    resp.status(201);
    resp.json(doc);
  })
  .catch(function(err) {
    resp.status(err.statusCode || 500);
    resp.json({status: err.statusCode || 500, message: err.message});
  });
};

/**
 * Function to get all companies on database
 */
this.delete = function(req, resp) {
  Promise.resolve()
  return dao.delete(req)
  .then(function(doc) {
    resp.status(201);
    resp.json(doc);
  })
  .catch(function(err) {
    resp.status(err.statusCode || 500);
    resp.json({status: err.statusCode || 500, message: err.message});
  });
};

module.exports = this;<commit_msg>removing unecessary promises<commit_after>'use strict'

var dao = require('../dao/dao');

/**
 * Function to add a new POI on database
 */
this.add = function(req, resp) {
  return dao.insert(req)
  .then(function(doc) {
    resp.status(201);
    resp.json(doc);
  })
  .catch(function(err) {
    resp.status(err.statusCode || 500);
    resp.json({status: err.statusCode || 500, message: err.message});
  });
};

/**
 * Function to get all companies on database
 */
this.get = function(req, resp) {
  return dao.findAll(req)
  .then(function(doc) {
    resp.status(201);
    resp.json(doc);
  })
  .catch(function(err) {
    resp.status(err.statusCode || 500);
    resp.json({status: err.statusCode || 500, message: err.message});
  });
};

/**
 * Function to get all companies on database
 */
this.update = function(req, resp) {
  return dao.update(req)
  .then(function(doc) {
    resp.status(201);
    resp.json(doc);
  })
  .catch(function(err) {
    resp.status(err.statusCode || 500);
    resp.json({status: err.statusCode || 500, message: err.message});
  });
};

/**
 * Function to get all companies on database
 */
this.delete = function(req, resp) {
  return dao.delete(req)
  .then(function(doc) {
    resp.status(201);
    resp.json(doc);
  })
  .catch(function(err) {
    resp.status(err.statusCode || 500);
    resp.json({status: err.statusCode || 500, message: err.message});
  });
};

module.exports = this;
{'fraction_non_alphanumeric': 0.1819650937297996, 'fraction_numerical': 0.024240465416936006, 'mean_word_length': 3.4340974212034383, 'pattern_counts': {'":': 1, '<': 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': '3591700', 'n_tokens_mistral': 1136, 'n_tokens_neox': 1070, 'n_words': 221}