{"size": 868, "ext": "js", "max_stars_repo_path": "routes/api.js", "max_stars_repo_name": "Mdudzik92/mattsworkouttracker", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "routes/api.js", "max_issues_repo_name": "Mdudzik92/mattsworkouttracker", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "routes/api.js", "max_forks_repo_name": "Mdudzik92/mattsworkouttracker", "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": 31.0, "max_line_length": 64, "alphanum_fraction": 0.5322580645}
const Workout = require("../models/workout");
const setRoute = require("express").Router();

    setRoute.get("/api/workouts", (req, res) => {
        Workout.find({}).then(workout => {res.json(workout)});
    });
    
    setRoute.post("/api/workouts", (req, res) => {
        Workout.create({}).then(workout => {res.json(workout)});
    });

    setRoute.put("/api/workouts/:id", (req, res) => {
        // const workoutId = req.id;
        // let savedExercises = [];
        Workout.findByIdAndUpdate(req.params.id, 
            { $push: { exercises: req.body } },
            { new: true, runValidators: true })
            .then(workout => res.json(workout))
    });

    setRoute.get("/api/workouts/range", (req, res) => {
        Workout.find({}).limit(7)
        .then(workout => {
            res.json(workout);
        });
    })

module.exports = setRoute;