<commit_before>const router = require('express').Router();
const bodyParser = require('body-parser').json();

const List = require('../models/list-schema.js');


router
    .get('/', (req, res, next) => {
        List.find()
            .lean()
            // .populate('item')   
            .then(lists => res.send(lists))
            .catch(next);
    })

    .get('/:id', (req, res, next) => {
        List.findById(req.params.id)
            .lean()
            // .populate('item')
            .then(list => {
                if(!list) {
                    res.status(404).send( {error: `Id ${req.params.id} Not Found`});
                }
                else {
                    res.send(list);
                }
            })
            .catch(next);
    })

    .post('/', bodyParser, (req, res, next) => {
        new List(req.body).save
            .then(list => res.send(list))
            .catch(next);
    })

    .post('/:id/item', bodyParser, (req, res, next) => {
        new List(req.body).findByIdAndUpdate(req.params.id, { item: req.body.item_id})
            .then(list => { res.send(list); })
            .catch(next);
    });


module.exports = router;<commit_msg>POST '/' corrected and working when req ref types commented out<commit_after>const router = require('express').Router();
const bodyParser = require('body-parser').json();

const List = require('../models/list-schema.js');


router
    .get('/', (req, res, next) => {
        List.find()
            .lean()
            // .populate('item')   
            .then(lists => res.send(lists))
            .catch(next);
    })

    .get('/:id', (req, res, next) => {
        List.findById(req.params.id)
            .lean()
            // .populate('item')
            .then(list => {
                if(!list) {
                    res.status(404).send( {error: `Id ${req.params.id} Not Found`});
                }
                else {
                    res.send(list);
                }
            })
            .catch(next);
    })

    .post('/', bodyParser, (req, res, next) => {
        new List(req.body).save()
            .then(list => res.send(list))
            .catch(next);
    })

    .post('/:id/item', bodyParser, (req, res, next) => {
        List.findByIdAndUpdate(req.params.id, { item: req.body.item_id})
            .then(list => res.send(list))
            .catch(next);
    });


module.exports = router;
{'fraction_non_alphanumeric': 0.18726746589499793, 'fraction_numerical': 0.0024803637866887144, 'mean_word_length': 1.4897119341563787, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '3483371', 'n_tokens_mistral': 754, 'n_tokens_neox': 730, 'n_words': 131}