<commit_before>'use strict';
const GroceryItem = require('../models/GroceryItem');

module.exports = function(app) {
    app.route('/api/items')
        .get((req, res) => {
            GroceryItem.find({})
                .exec((err, items) => {
                    if (err) {
                        return res.send([]);
                    }
                    return res.send(items);
                });
        })
        .post((req, res) => {
            let item = req.body;
            new GroceryItem(item).save((err) => {
                if (err) {
                    return res.status(500).send({
                        message: err.message
                    });
                }
                return res.status(300).send();
            });
        });
    app.route('/api/items/:id')
        .delete((req, res) => {
            GroceryItem.find({
                _id: req.params.id
            }).remove();
            return res.status(200);
        })
        .patch((req, res) => {
            GroceryItem.findOne({
                _id: req.body._id
            }, (err, item) => {
                for(let key in req.body) {
                    item[key] = req.body[key];
                }
                item.save();
                return res.status(200);
            });
        });
};
<commit_msg>Fixing Bug on delete end point<commit_after>'use strict';
const GroceryItem = require('../models/GroceryItem');

module.exports = function(app) {
    app.route('/api/items')
        .get((req, res) => {
            GroceryItem.find({})
                .exec((err, items) => {
                    if (err) {
                        return res.send([]);
                    }
                    return res.send(items);
                });
        })
        .post((req, res) => {
            let item = req.body;
            new GroceryItem(item).save((err) => {
                if (err) {
                    return res.status(500).send({
                        message: err.message
                    });
                }
                return res.status(300).send();
            });
        });
    app.route('/api/items/:id')
        .delete((req, res) => {
            GroceryItem.remove({
                _id: req.params.id
            }, (err) => {
                if(err) {
                    return res.status(500).send(err.message);
                }
                return res.status(200);
            });
        })
        .patch((req, res) => {
            GroceryItem.findOne({
                _id: req.body._id
            }, (err, item) => {
                for(let key in req.body) {
                    item[key] = req.body[key];
                }
                item.save();
                return res.status(200);
            });
        });
};

{'fraction_non_alphanumeric': 0.14949928469241774, 'fraction_numerical': 0.009656652360515022, 'mean_word_length': 0.9628070175438597, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, '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': '2935412', 'n_tokens_mistral': 788, 'n_tokens_neox': 727, 'n_words': 126}