<commit_before>import Shred from '../models/Shred.model';
/*create new shred. */
function create(req, res, next) {
  const shred = new Shred({
    ownerId: req.params.ownerid,
    shredSize: req.params.shredsize
  });

  shred.save()
    .then(savedShred => res.json(savedShred))
    .catch(e => next(e));
}
/*Load shred and append to req.*/
function get(req, res,next) {
  Shred.get(req.params.shredId)
    .then((shred) => {
      req.shred = shred;
      return res.json(shred);
    })
    .catch(e => next(e));
}
/*Delete shred*/
function remove(req, res, next) {
  const shred = req.shred;
  shred.remove()
    .then(deletedShred => res.json(deletedShred))
    .catch(e => next(e));
}

export default { create,get,remove };
<commit_msg>reviewed Shred controller<commit_after>import Shred from '../models/Shred.model';

// create new shred
function create(req, res, next) {
  const shred = new Shred({
    owner: req.body.owner,
    size: req.body.shredsize
  });

  shred.save()
    .then(savedShred => res.json(savedShred))
    .catch(e => next(e));
}

// Load shred and return it in response
function get(req, res, next) {
  Shred.findOne({_id: req.body.shredId})
    .then((shred) => res.json(shred)})
    .catch(e => next(e));
}

// remove shred
function remove(req, res, next) {
  Shred.findOne({_id: req.body.shredId})
    .then(deletedShred => {
      Shred.remove({_id: deletedShred._id})
        .then(() => res.json(deletedShred))
        .catch(e => next(e));
    })
    .catch(e => next(e));
}

export default { create, get, remove };

{'fraction_non_alphanumeric': 0.1791237113402062, 'fraction_numerical': 0.0, 'mean_word_length': 3.1859838274932613, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '7135291', 'n_tokens_mistral': 576, 'n_tokens_neox': 565, 'n_words': 123}