{"size": 597, "ext": "js", "max_stars_repo_path": "api/foods/router.js", "max_stars_repo_name": "Potluck-Planner-1-Oct2021/back-end", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "api/foods/router.js", "max_issues_repo_name": "Potluck-Planner-1-Oct2021/back-end", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "api/foods/router.js", "max_forks_repo_name": "Potluck-Planner-1-Oct2021/back-end", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.9, "max_line_length": 48, "alphanum_fraction": 0.5695142379}
const router = require("express").Router()
const { getAll } = require("./modal")


router.get("/", async (req, res, next) => {
    try {
        const allFoods = await getAll()
        res.status(200).json(allFoods)

    } catch (error) {
        next(error)
    }

})


router.get("/:foodName", (req, res, next) => {
    const { foodName } = req.params
    getAll().then(foods => {

        const searchedFor = foods.filter(item =>
            item.food_name === foodName)

        console.log(searchedFor)
        res.status(200).json(searchedFor)

    }).catch(next)
})

module.exports = router