import models from '../models';

const favorite = models.Favorite;

/**
 * @exports addToFavorite
 * @param  {obj} req request object
 * @param  {obj} res result object
 * @return {obj}  newUser object
 */
export const addToFavorite = (req, res) => {
  const userId = req.session.user.id;
  const recipeId = req.params.recipeId;
  const newFavorite = favorite
    .create({
      userId,
      recipeId
    })
    .then((createdFavorite) => {
      res.status(201).send(createdFavorite);
    })
    .catch(() => res.status(401).send({ error: 'Error Recipe to Favorites' }));

  return newFavorite;
};

export const removeFromFavorite = () => {

};

@@ -542,16 +542,23 @@
  'Error 
+Adding 
 Recipe t
@@ -644,12 +644,697 @@
 () =%3E %7B%0A%0A%7D;%0A
+%0A%0A/**%0A * @exports getFavRecipes%0A * @param  %7Bobj%7D req request object%0A * @param  %7Bobj%7D res result object%0A * @return %7Bobj%7D  newUser object%0A */%0Aexport const getFavRecipes = (req, res) =%3E %7B%0A  const userId = req.params.userId;%0A  const favRecipes = favorite%0A    .findAll(%7B%0A      where: %7B userId %7D,%0A      include: %5B%0A        %7B model: models.Recipes %7D%0A      %5D%0A    %7D)%0A    .then((foundRecipes) =%3E %7B%0A      if (!foundRecipes) %7B%0A        return res.status(201).send(%7B%0A          message: 'No Stored Favorite Recipes found',%0A        %7D);%0A      %7D%0A%0A      return res.status(201).send(foundRecipes);%0A    %7D)%0A    .catch(() =%3E res.status(401).send('Unable to fetch favorite recipes'));%0A%0A  return favRecipes;%0A%7D;%0A

Create getFavRecipes in favorites Controller