<commit_before>const Router = require('express').Router;
const Plan = require(__dirname + '/../models/plan.js');
const bodyParser = require('body-parser').json();

var planRouter = module.exports = new Router();


planRouter.get('/plan', (req, res) => {
  Plan.find({}, (err, data) => {
    if (err) console.log(err);
    res.status(200).json(data);
  });
});

planRouter.post('/plan', bodyParser, (req, res) => {
  var newPlan = new Plan(req.body);
  newPlan.save((err, data) => {
    if (err) console.log(err);
    res.status(200).json(data);
  });
});<commit_msg>put, delete, errorHandler<commit_after>const Router = require('express').Router;
const Plan = require(__dirname + '/../models/plan.js');
const bodyParser = require('body-parser').json();
const errorHandler = require(__dirname + '/../lib/errorHandler.js');

var planRouter = module.exports = new Router();


planRouter.get('/plan', (req, res) => {
  Plan.find({}, (err, data) => {
    if (err) errorHandler(err, res);
    res.status(200).json(data);
  });
});

planRouter.post('/plan', bodyParser, (req, res) => {
  var newPlan = new Plan(req.body);
  newPlan.save((err, data) => {
    if (err) return errorHandler(err, res);
    res.status(200).json(data);
  });
});

planRouter.put('/plan/:id', bodyParser, (req, res) => {
  var planData = req.body;
  delete planData._id;
  Plan.update({ _id: req.params.id }, planData, (err) => {
    if (err) return errorHandler(err, res);
    res.status(200).json({ msg: 'Updated the plan entry with put' });
  });
});

planRouter.delete('/plan/:id', bodyParser, (req, res) => {
  Plan.findOneAndRemove({ _id: req.params.id }, (err) => {
    if (err) return errorHandler(err, res);
    res.status(200).json({ msg: 'Deleted a plan entry' });
  });
});
{'fraction_non_alphanumeric': 0.21493728620296465, 'fraction_numerical': 0.010262257696693273, 'mean_word_length': 4.057636887608069, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '6774153', 'n_tokens_mistral': 613, 'n_tokens_neox': 601, 'n_words': 133}