Giter Site home page Giter Site logo

lab-ironbeers's Introduction

logo_ironhack_blue 7

IronBeers

Introduction

In this lab you will create a web app where the user will be able to see a list of beers or check one randomly. For the exercise, we will work with the PunkAPI database, through it's NPM Package. The package has some methods that retrieve beers with some info about them and fits perfect for our example.

⚠️ Notice that this setup has handlebars as a view engine. If you are to use some other view engine (like ejs) you have to install that package and edit your app.js manually.

Requirements

  • Fork this repo

Purpose

  • Create a basic web app, where you can Check the beers or get a random beer.
  • Use PunkAPI Database

Submission

  • Upon completion, run the following commands
$ git add .
$ git commit -m "done"
$ git push origin master
  • Create Pull Request so your TAs can check up your work.

Instructions

Iteration 1 - Layout

First, we need to create our layout.

Inside the views folder, create a layout file. Our layout should look like this:

image

You will find the colors and fonts on the css file. Remember to link the css file to your main layout.

The navbar includes three elements:

  • Home. ----> Should navigate to /.
  • Beers. ----> Should navigate to /beers.
  • Random Beer. ----> Should navigate to /random-beers.

Iteration 2 - The Index

In the index view file you should include the beer image you have on the /public/images, with two buttons: Check the Beers! and Check a Random Beer. Both should navigate to the same routes we have on our nav.

image

Iteration 3 - The Beers Route

Create a /beers route inside the app.js file. You will also need a beers view file to render every time we call this route.

Inside the /beers route, call to the getBeers() method of our PunkAPI package. The package will return you an array of 25 beers, and you should pass that array to the beers view.

punkAPI.getBeers()
  .then(beers => {

  })
  .catch(error => {
    console.log(error)
  })

Remember you should call the render method after getting the beers from our package. That means, inside the then.

Iteration 4 - Beers Views

In the beers view, loop over the beers array. On every iteration, you should call a partial passing the info about each beer.

Iteration 5 - Beer Partial

Since each beer will be displayed in the same way, you should create a partial to display each beer. First, we need to register where our partials will be located. So you need to add the following code to the app.js file:

hbs.registerPartials(__dirname + '/views/partials')

Now, you should create a partials folder inside the views, and beerPartial file inside the partials folder. Our beerPartial will display an image, name, description, and tagline of the beer. It should look like the following:

image

After creating the partial, and loop over the array of beers, on our /beers route, we should have the following:

image

Iteration 6 - Random Beer

Finally, let's create our /random-beer route. Inside our route you should call the getRandom() method of the PunkAPI package and after receiving the info, render the randomBeer file and pass the data of the beer.

punkAPI.getRandom()
  .then(beers => {

  })
  .catch(error => {
    console.log(error)
  })

On the randomBeer you should print the random beer you get. You should display an image, name, description, tagline, food pairing and brewer tips. It should look like the following:

image

Happy Coding! ❤️

lab-ironbeers's People

Contributors

sandrabosk avatar marcospalaciosiii avatar papuarza avatar rundiye avatar jackwatk avatar tawebbcn avatar axelgar avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.