diff --git a/app.js b/app.js index a206dd8d91..2f583275e2 100644 --- a/app.js +++ b/app.js @@ -2,10 +2,8 @@ const express = require('express'); const hbs = require('hbs'); const path = require('path'); -const PunkAPIWrapper = require('punkapi-javascript-wrapper'); const app = express(); -const punkAPI = new PunkAPIWrapper(); app.set('view engine', 'hbs'); app.set('views', path.join(__dirname, 'views')); @@ -14,6 +12,11 @@ app.use(express.static(path.join(__dirname, 'public'))); // Register the location for handlebars partials here: +hbs.registerPartials(__dirname + "/views/partials"); +hbs.registerHelper("eq", function (a, b) { + return a===b; +}); + // ... // Add the route handlers here: @@ -22,4 +25,26 @@ app.get('/', (req, res) => { res.render('index'); }); +app.get(`/breweries`, (req, res) => { + fetch(`https://api.openbrewerydb.org/v1/breweries`) + .then((response) => response.json()) + .then((response) => { + res.render(`breweries`, { breweries: response }); + }); +}); + +app.get(`/randomBrewery`, (req, res) => { + fetch(`https://api.openbrewerydb.org/v1/breweries/random`) + .then((response) => response.json()) + .then((response) => res.render(`randomBrewery`, { brewery: response[0] })); +}); + + +app.get(`/breweries/:id`, (req, res) => { + const id = req.params.id; + fetch(`https://api.openbrewerydb.org/v1/breweries/${id}`) + .then((response) => response.json()) + .then((response) => res.render(`randomBrewery`, { brewery: response})); +}); + app.listen(3000, () => console.log('🏃 on port 3000')); diff --git a/package.json b/package.json index 111c4e477d..c2a6f02c10 100644 --- a/package.json +++ b/package.json @@ -11,5 +11,7 @@ "express": "^4.17.1", "hbs": "^4.1.1", "punkapi-javascript-wrapper": "^1.0.2" - } + }, + "description": "", + "author": "" } diff --git a/public/images/brewery.webp b/public/images/brewery.webp new file mode 100644 index 0000000000..3c06390e2e Binary files /dev/null and b/public/images/brewery.webp differ diff --git a/public/stylesheets/styles.css b/public/stylesheets/styles.css index 251470be83..24f3292666 100644 --- a/public/stylesheets/styles.css +++ b/public/stylesheets/styles.css @@ -5,3 +5,118 @@ dark-blue: #0a2c42; grey: #bfbfbf; font-family: Arial, Helvetica, sans-serif; */ +body { + margin: 0; +} + +h1 { + font-size: 40px; + text-align: center; +} + +.random { + text-align: center; +} + +.navbar { + background-color: #2081c3; + color: #f7f9f9; + display: flex; + justify-content: space-around; + align-items: center; + height: 100px; +} + +.navbar a { + color: #f7f9f9; + text-decoration: none; +} + +#home-img { + padding: 100px 100px 40px; + height: 500px; + width: 700px; + margin: auto; + display: block; +} + +.links { + display: flex; + flex-direction: column; + align-items: center; +} + +.links a { + color: #f7f9f9; + text-decoration: none; + background-color: #2081c3; + padding: 20px 10px; + border: none; + border-radius: 5px; + margin-bottom: 10px; +} + +.grid { + display: grid; + grid-template-columns: 1fr 1fr 1fr; + grid-gap: 5px +} + +.card { + border : 1px solid #ccc; + border-radius: 5px; + padding: 10px; +} + +.card a { + text-decoration: none; + color: #111010; +} + +.micro { + padding: 5px; + border-radius: 15px; + background-color: orange; + color: white; + font-size: 12px; +} + +.large { + padding: 5px; + border-radius: 15px; + background-color: green; + color: white; + font-size: 12px; +} + +.brewpub { + padding: 5px; + border-radius: 15px; + background-color: purple; + color: white; + font-size: 12px; +} + +.closed { + padding: 5px; + border-radius: 15px; + background-color: black; + color: white; + font-size: 12px; +} + +.proprietor { + padding: 5px; + border-radius: 15px; + background-color: blue; + color: white; + font-size: 12px; +} + +.contract { + padding: 5px; + border-radius: 15px; + background-color: red; + color: white; + font-size: 12px; +} \ No newline at end of file diff --git a/views/breweries.hbs b/views/breweries.hbs new file mode 100644 index 0000000000..f60cf22689 --- /dev/null +++ b/views/breweries.hbs @@ -0,0 +1,24 @@ +
{{city}}
+
+
\ No newline at end of file
diff --git a/views/layout.hbs b/views/layout.hbs
new file mode 100644
index 0000000000..35fd19ae9c
--- /dev/null
+++ b/views/layout.hbs
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+ Develop by Javi ;) © 2024
\ No newline at end of file diff --git a/views/partials/navbar.hbs b/views/partials/navbar.hbs new file mode 100644 index 0000000000..96758231d1 --- /dev/null +++ b/views/partials/navbar.hbs @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/views/randomBrewery.hbs b/views/randomBrewery.hbs new file mode 100644 index 0000000000..d16122dbf3 --- /dev/null +++ b/views/randomBrewery.hbs @@ -0,0 +1,19 @@ +Name: {{brewery.name}}
+Brewery Type: {{brewery.brewery_type}}
+Adress 1: {{brewery.address_1}}
+{{#if brewery.adress_2}}Adress 2: {{brewery.adress_2}}
{{/if}} +{{#if brewery.adress_3}}Adress 3: {{brewery.adress_3}}
{{/if}} +City: {{brewery.city}}
+State/Province: {{brewery.state_province}}
+Postal Code: {{brewery.postal_code}}
+Country: {{brewery.country}}
+{{#if brewery.longitude}}Longitude: {{brewery.longitude}}
{{/if}} +{{#if brewery.latitude}}Latitude: {{brewery.latitude}}
{{/if}} +Phone: {{brewery.phone}}
+Website URL: + {{brewery.website_url}}
+State: {{brewery.state}}
+Street: {{brewery.street}}
+