This site was created by Jason Williams. It uses data from mapbox.com and darksky.net!
diff --git a/web-server/package.json b/web-server/package.json index 933c6b9..f3cda2f 100644 --- a/web-server/package.json +++ b/web-server/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "start": "node src/app.js" }, "keywords": [], "author": "", diff --git a/web-server/src/app.js b/web-server/src/app.js index f7549e1..4f2fb30 100644 --- a/web-server/src/app.js +++ b/web-server/src/app.js @@ -5,6 +5,7 @@ const geocode = require('./utils/geocode') const forecast = require('./utils/forecast') const app = express() +const port = process.env.PORT || 4200 // Define paths for Express config const publicDirectoryPath = path.join(__dirname, '../public') @@ -96,6 +97,6 @@ app.get('*', (req, res) => { }) }) -app.listen(4200, () => { - console.log('Server is up on port 4200.') +app.listen(port, () => { + console.log('Server is up on port ' + port + '.') }) diff --git a/web-server/src/utils/forecast.js b/web-server/src/utils/forecast.js index f6fe52d..11cb167 100644 --- a/web-server/src/utils/forecast.js +++ b/web-server/src/utils/forecast.js @@ -1,7 +1,7 @@ const request = require('request') const forecast = (latitude, longitude, callback) => { - const url = 'https://api.darksky.net/forecast/0466bccb953c0b9daeb091a529da2c0d/' + latitude + ',' + longitude + '?units=si' + const url = 'https://api.darksky.net/forecast/bae9e39ba5c00299d5a95b35c1ae20cc/' + latitude + ',' + longitude + '?units=si' request({ url, json: true }, (error, {body}) => { if (error) { @@ -9,7 +9,7 @@ const forecast = (latitude, longitude, callback) => { } else if (body.error) { callback('Unable to find location', undefined) } else { - callback(undefined, body.daily.data[0].summary + ' It is currently ' + body.currently.temperature + ' degrees out. There is a ' + body.currently.precipProbability + '% chance of rain.') + callback(undefined, body.daily.data[0].summary + ' It is currently ' + body.currently.temperature + ' degrees out. Today\'s high will be ' + body.daily.data[0].temperatureMax + ' degrees, with a low of ' + body.daily.data[0].temperatureMin + '. There is a ' + body.currently.precipProbability + '% chance of rain.') } }) } diff --git a/web-server/src/utils/geocode.js b/web-server/src/utils/geocode.js index c906174..fbbd4d0 100644 --- a/web-server/src/utils/geocode.js +++ b/web-server/src/utils/geocode.js @@ -1,7 +1,7 @@ const request = require('request') const geocode = (address, callback) => { - const url = 'https://api.mapbox.com/geocoding/v5/mapbox.places/' + encodeURIComponent(address) + '.json?access_token=pk.eyJ1IjoiamF5d2xsIiwiYSI6ImYyZjkyMGNlOTgyNGQ5ZWM5ZDExN2FjNGYwMDZmNTQ4In0.y3lv5ddmGhVNSL7wfMpB0g&limit=1' + const url = 'https://api.mapbox.com/geocoding/v5/mapbox.places/' + encodeURIComponent(address) + '.json?access_token=pk.eyJ1IjoiamFzb24zMmRldiIsImEiOiJjazFsNHd5djcwMXptM2htbW8zM3MyZGxuIn0.-TtNNGFysQPQRfGR1P8DUA&limit=1' request({ url, json: true }, (error, {body}) => { if (error) { diff --git a/web-server/templates/views/about.hbs b/web-server/templates/views/about.hbs index 2b58b9e..f440f3a 100644 --- a/web-server/templates/views/about.hbs +++ b/web-server/templates/views/about.hbs @@ -11,6 +11,7 @@
This site was created by Jason Williams. It uses data from mapbox.com and darksky.net!