{"size": 590, "ext": "js", "max_stars_repo_path": "routes/apiRoutes/notesRoutes.js", "max_stars_repo_name": "SirTedDanson/note-taker-application", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "routes/apiRoutes/notesRoutes.js", "max_issues_repo_name": "SirTedDanson/note-taker-application", "max_issues_repo_issues_event_min_datetime": "2022-01-20T21:17:26.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-22T07:35:32.000Z", "max_forks_repo_path": "routes/apiRoutes/notesRoutes.js", "max_forks_repo_name": "SirTedDanson/note-taker-express", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 4, "max_forks_count": null, "avg_line_length": 25.652173913, "max_line_length": 63, "alphanum_fraction": 0.6152542373}
const router = require('express').Router();
const { updateNotes, deleteNote } = require('../../lib/notes');
const notes = require('../../db/db');

// ======= Back end API calls ======= \\
// Get data from db.json
router.get('/notes', (req, res) => {
  res.json(notes);
});
// Delete data based on ID from db.json
router.delete('/notes', (req, res) => {
  const newNotes = deleteNote(req.query.id, notes);

  res.json(newNotes);
});
// Add new data to db.json
router.post('/notes', (req, res) => {
  const note = updateNotes(req.body, notes);

  res.json(note);
});

module.exports = router;