shiftymitch / cookbook

Cookbook is a community driven recipe database, which gives users the ability to sign-up, submit recipes, search for community recipes, and search a larger 3rd party database.
https://https://the-cookbook-app.herokuapp.com/
MIT License
4 stars 2 forks source link

Cookbook

Build Status

cookbook-screenshot


Table of Contents

Your section headers will be used to reference location of destination.


Description

Cookbook is a community driven recipe database, which gives users the ability to sign-up, submit recipes, search for community recipes, and search a larger 3rd party database.

Cookbook skips the unnecessary and presents straight-forward recipes, including name, photo, ingredients, and instructions. No filler, no life-story needed.

Our app is purpose-built from recipe submission to display to provide only the information you need to go from grocery store to kitchen.


How to Use

Simply open the application in any browser. Once the page is loaded, signup, login, and begin adding and searching for recipes. Cookbook is community-driven, so why not share your favorite recipes!


Installation

Cookbook is live here


Technologies

Axios\ Bulma\ dotenv\ Express\ Handlebars\ Moment.js\ multer\ MySQL\ Node.js\ Passport.js\ Sequelize\ spoonacular API


Roadmap

Future improvements for the application:


Code Samples

Routes returning a user recipe or spoonacular API random recipes:

app.get("/recipe/:id", function (req, res) {
    const searchId = req.params.id;

    db.Recipe.findOne({
      where: { id: searchId },
      include: db.Ingredient
    })
      .then((dbResult) => {
        console.log(dbResult.dataValues)
        const recipe = dbResult.dataValues;
        let hbsObject = {
          recipe: {
            id: recipe.id,
            title: recipe.title,
            description: recipe.description,
            instructions: recipe.instructions,
            createdAt: () => {
              return recipe.createdAt = moment().format("MMM Do YYYY");
            },
            ingredients: recipe.Ingredients.map(ingredient => {
              return {
                name: ingredient.name,
                qty: ingredient.qty,
                measurement: ingredient.measurement
              }
            })
          }
        };

        res.render("recipe", {
          recipe: hbsObject.recipe
        })
      })
      .catch(err => console.log(err))
  });
app.get("/api/random-recipe", function (req, res) {

    let keys = [process.env.SPOON_API_KEY_1, process.env.SPOON_API_KEY_2, process.env.SPOON_API_KEY_3, process.env.SPOON_API_KEY_4];

    let key = keys[Math.floor(Math.random() * keys.length)];

    axios.get("https://api.spoonacular.com/recipes/random?number=2&tags=dinner&apiKey=" + key)
      .then((response) => {
        res.send(response.data);
      })
      .catch((error) => {
        console.log(error);
      })

License

MIT © shiftymitch, nvalline, nabeek


Contributors

Developer GitHub
Mitch Henderson shiftymitch
Nate Valline nvalline
Nick Beekhuizen nabeek

Back to the Top