/** @module root/router */
'use strict';
// vim: set ts=2 sw=2 et tw=80:

const express = require('express');
const router = express.Router();

const mongoose = require('mongoose');
const Favorite = mongoose.model('Favorite');

const { error, renderFav } = require('../utils');

router.get('/', (req, res) => {
  Favorite.find({ bookmarked: true }, (err, favs) => {
    if (err) {
      return error(err, res);
    }

    renderFav(req, res, favs);
  });
});

/** router for /root */
module.exports = router;
