<commit_before>'use strict';

var ContactProvider = require('../data').ContactProvider;
var contactData = new ContactProvider('localhost', 27017);

// var contacts = [
//     {id: 0, name: "Alice", phone:"555-1234"},
//     {id: 1, name: "Bob", phone:"555-4321"},
//     {id: 2, name: "Carol", phone:"555-5678"},
//     {id: 3, name: "Dave", phone:"555-8765"}
// ];

exports.displayAllContacts = function(req, res) {
    contactData.findAll(function(error, contacts) {
        res.json(contacts);
    });
};

exports.displayContact = function(req, res) {
    contactData.findById(req.params.id, function(error, contact) {
        if (error) {
            res.statusCode = 404;
            return res.send('Error 404: No contact found');
        }
        res.json(contact);
    });
};

exports.postNewContact = function(req, res) {
    if (!req.body.hasOwnProperty('name') || !req.body.hasOwnProperty('phone')) {
        res.statusCode = 500;
        return res.send('Error: Post syntax incorrect.');
    }

    contactData.save({
        name: req.body.name,
        phone: req.body.phone
    }, function(error, contact) {
        res.json(contact);
    });
};

exports.updateContact = function(req, res) {
    if (!req.body.hasOwnProperty('name') || !req.body.hasOwnProperty('phone')) {
        res.statusCode = 500;
        return res.send('Error: Post syntax incorrect.');
    }
    contactData.update(req.params.id, {
        name: req.body.name,
        phone: req.body.phone
    }, function(error, contact) {
        if (error) {
            res.statusCode = 500;
            return res.send('Error occured.');
        }
        res.json(contact);
    });
};

exports.deleteContact = function(req, res) {
    contactData.delete(req.params.id, function(error, contact) {
        if (error) {
            res.statusCode = 500;
            return res.send('Error: deleting');
        }
        res.json(true);
    });
};
<commit_msg>Remove commented dummy data store<commit_after>'use strict';

var ContactProvider = require('../data').ContactProvider;
var contactData = new ContactProvider('localhost', 27017);

exports.displayAllContacts = function(req, res) {
    contactData.findAll(function(error, contacts) {
        res.json(contacts);
    });
};

exports.displayContact = function(req, res) {
    contactData.findById(req.params.id, function(error, contact) {
        if (error) {
            res.statusCode = 404;
            return res.send('Error 404: No contact found');
        }
        res.json(contact);
    });
};

exports.postNewContact = function(req, res) {
    if (!req.body.hasOwnProperty('name') || !req.body.hasOwnProperty('phone')) {
        res.statusCode = 500;
        return res.send('Error: Post syntax incorrect.');
    }

    contactData.save({
        name: req.body.name,
        phone: req.body.phone
    }, function(error, contact) {
        res.json(contact);
    });
};

exports.updateContact = function(req, res) {
    if (!req.body.hasOwnProperty('name') || !req.body.hasOwnProperty('phone')) {
        res.statusCode = 500;
        return res.send('Error: Post syntax incorrect.');
    }
    contactData.update(req.params.id, {
        name: req.body.name,
        phone: req.body.phone
    }, function(error, contact) {
        if (error) {
            res.statusCode = 500;
            return res.send('Error occured.');
        }
        res.json(contact);
    });
};

exports.deleteContact = function(req, res) {
    contactData.delete(req.params.id, function(error, contact) {
        if (error) {
            res.statusCode = 500;
            return res.send('Error: deleting');
        }
        res.json(true);
    });
};

{'fraction_non_alphanumeric': 0.1602721088435374, 'fraction_numerical': 0.02122448979591837, 'mean_word_length': 2.4909781576448244, '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': '4961836', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1122, 'n_words': 218}