{"size": 1053, "ext": "js", "max_stars_repo_path": "controllers/burgers_controller.js", "max_stars_repo_name": "alexhstrickland/Eat_Da_Burger", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "controllers/burgers_controller.js", "max_issues_repo_name": "alexhstrickland/Eat_Da_Burger", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "controllers/burgers_controller.js", "max_forks_repo_name": "alexhstrickland/Eat_Da_Burger", "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": 27.7105263158, "max_line_length": 72, "alphanum_fraction": 0.5527065527}
const express = require('express');
const router = express.Router();
const burger = require('../models/burger.js');

  router.get('/', (req, res) => {
    burger.all((results) => {
      const hbsObject = {
        burgers: results,
      };
      console.log('hbsObject', hbsObject);
      res.render('index', hbsObject);
    });
  });
  
  router.post('/api/burgers', (req, res) => {
    burger.create({burger_name: req.body.burger_name }, results  => {
      if (results.changedRows === 0) {
        // If no rows were changed, then the ID must not exist, so 404
        return res.status(404).end();
      }
      res.status(200).end();
    }
  );
  });
  
  router.put('/api/burgers/:id', (req, res) => {
    burger.update(req.body, req.paramas.id, results => {
        if (results.changedRows === 0) {
          // If no rows were changed, then the ID must not exist, so 404
          return res.status(404).end();
        }
        res.status(200).end();
      }
    );
  });
  
  // Export routes for server.js to use.
  module.exports = router;