From c9430a45bf65de667436c39d31b0a27bd60e49ff Mon Sep 17 00:00:00 2001 From: NGK Sternhagen Date: Sat, 23 Jan 2016 09:53:40 -0800 Subject: [PATCH 1/3] delete trailing whitespace --- app.js | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/app.js b/app.js index cb64891..fb4f771 100644 --- a/app.js +++ b/app.js @@ -18,7 +18,7 @@ app.use(session({ resave: false, saveUninitialized: true })) - + // Our custom app configs // Contains Oauth2 key/secret var config = require('./config.json'); @@ -31,20 +31,20 @@ var oauth2 = require('simple-oauth2')({ tokenPath: '/o/token/', revocationPath: '/oauth2/revoke/' }); - -// Authorization uri definition + +// Authorization uri definition var authorization_uri = oauth2.authCode.authorizeURL({ redirect_uri: 'http://localhost:3000/callback', scope: 'read', state: 'simple_state' }); - -// Initial page redirecting to BuildingOS + +// Initial page redirecting to BuildingOS app.get('/auth', function (req, res) { res.redirect(authorization_uri); }); - -// Callback service parsing the authorization token and asking for the access token + +// Callback service parsing the authorization token and asking for the access token app.get('/callback', function (req, res) { var code = req.query.code; console.log('/callback'); @@ -53,12 +53,12 @@ app.get('/callback', function (req, res) { code: code, redirect_uri: 'http://localhost:3000/callback' }, saveToken); - + function saveToken(error, result) { console.log('result', util.inspect(result)); console.log('error', util.inspect(error)); - if (error) { - console.log('Access Token Error', error.message); + if (error) { + console.log('Access Token Error', error.message); } else { // stash the token in the user session @@ -70,7 +70,7 @@ app.get('/callback', function (req, res) { } }); - + // root of the app. Just has a link to kick off the auth process app.get('/', function (req, res) { res.render('index', { title: 'Hey', message: 'Hello there!'}); @@ -113,12 +113,12 @@ app.get('/data', function (req, res){ var vals = {'a':1, 'b': 2, 'c': 3}; var ts_reading = {}; ts_reading[ts] = vals; - readings.push(ts_reading); - }); - + readings.push(ts_reading); + }); + res.json({"data": readings}); }); - + // starting up the app and logging the address/port var server = app.listen(3000, function () { From af3d260a4f2b742f67f8496f88d494b25fa308f4 Mon Sep 17 00:00:00 2001 From: NGK Sternhagen Date: Sat, 23 Jan 2016 10:31:48 -0800 Subject: [PATCH 2/3] fix typo --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index fb4f771..b3723e5 100644 --- a/app.js +++ b/app.js @@ -89,7 +89,7 @@ app.get('/buildings', function (req, res){ request(options, function (error, response, body) { if (!error && response.statusCode == 200) { buildings = JSON.parse(body).data; - res.render('buildings', {title: 'Bulidings', buildings: buildings}); + res.render('buildings', {title: 'Buildings', buildings: buildings}); } }); }); From ebd83a1c7959428ba88ca7536b9b51a0aa33289a Mon Sep 17 00:00:00 2001 From: NGK Sternhagen Date: Sat, 23 Jan 2016 12:29:51 -0800 Subject: [PATCH 3/3] fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 217d9fa..66f533f 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,4 @@ In this app you are able to: - Show list of buildings - TODO: Select one from list - TODO: View Building with all meters -- TODO: Each meter should have an the type of resource and the most recent reading. +- TODO: Each meter should have the type of resource and the most recent reading.