<commit_before>const db = require('APP/db')
//ShoppingCart model doesn't actually exist yet
const ShoppingCart = db.model('cart');

module.exports = require('express').Router()
  .get('/:userID', (req, res, next) => {
    //ShoppingCart model doesn't actually exist yet
    let userID = req.params.userID;
    ShoppingCart.findOne({where: {userId: userID}})
    .then(cart => res.json(cart))
    .catch(next)
  })
  .put('/:userID', (req, res, next) => {
    let userID = req.params.userID;
    let cartInfo = req.body;
    ShoppingCart.findOne({where: {userId: userID}})
    .then(cart => {
      cart.update(cartInfo);
      res.status(204).json(cart);
    })
    .catch(next)
  })
  .post('/', (req, res, next) => {
    let newCart = req.body;
    ShoppingCart.create(newCart)
    .then(cart => res.status(201).json(cart))
    .catch(next)
  })
  .delete('/:userID', (req, res, next) => {
    let userID = req.params.userID;
    ShoppingCart.destroy({where: {userId: userID}})
    .then(cart => res.status(204).json(cart))
  })<commit_msg>updated shopping cart routes per <NAME>'s comments<commit_after>const db = require('APP/db')
const ShoppingCart = db.model('cart');

module.exports = require('express').Router()
  .get('/:userID', (req, res, next) => {
    ShoppingCart.findOne({where: {userId: req.params.userID}})
    .then(cart => res.json(cart))
    .catch(next)
  })
  .put('/:userID', (req, res, next) => {
    ShoppingCart.findOne({where: {userId: req.params.userID}})
    .then(cart => {
      cart.update(req.body);
      res.status(202).json(cart);
    })
    .catch(next)
  })
  .post('/', (req, res, next) => {
    ShoppingCart.create(req.body)
    .then(cart => res.status(201).json(cart))
    .catch(next)
  })
  .delete('/:userID', (req, res, next) => {
    ShoppingCart.destroy({where: {userId: req.params.userID}})
    .then( () => res.status(204))
  })
{'fraction_non_alphanumeric': 0.20447284345047922, 'fraction_numerical': 0.009584664536741214, 'mean_word_length': 3.359628770301624, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 20, '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': '6575610', 'n_tokens_mistral': 682, 'n_tokens_neox': 673, 'n_words': 125}