From f36f7795c1bf8d4422fde9d3a2fa38e1967339a6 Mon Sep 17 00:00:00 2001 From: martypdx Date: Thu, 12 Jan 2017 14:57:26 -0800 Subject: [PATCH] iot feedback --- lib/api/pet-snapshots-api.js | 1 + lib/api/pets-api.js | 2 +- lib/get-data.js | 2 ++ lib/lcd.js | 8 ++++---- main.js | 4 +++- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/api/pet-snapshots-api.js b/lib/api/pet-snapshots-api.js index f379bb8..064e6db 100644 --- a/lib/api/pet-snapshots-api.js +++ b/lib/api/pet-snapshots-api.js @@ -1,4 +1,5 @@ const superagent = require('superagent'); +// Pull the common host/api into own module or env variable const url = 'https://pawsio.herokuapp.com/api/pet-snapshots'; module.exports = { diff --git a/lib/api/pets-api.js b/lib/api/pets-api.js index 2e44783..4b16929 100644 --- a/lib/api/pets-api.js +++ b/lib/api/pets-api.js @@ -5,7 +5,7 @@ module.exports = { getAll(token) { return superagent.get(`${url}/all`) .set('authorization', `Bearer ${token}`) - .then(res => res.body) + .then(res => res.body) // what happen to semicolons??? }, getOne(token, id) { return superagent.get(`${url}/${id}`) diff --git a/lib/get-data.js b/lib/get-data.js index eb3ae3e..795ce56 100644 --- a/lib/get-data.js +++ b/lib/get-data.js @@ -4,6 +4,8 @@ const thermometer = require('./thermometer')(); const accelerometer = require('./accelerometer')(); const microphone = require('./microphone')(); +// I don't think I would have used the factory function pattern for +// the modules in this project. Just seems like extra work. module.exports = function getData() { return function getData() { return Promise.all([ diff --git a/lib/lcd.js b/lib/lcd.js index 663288f..22cb425 100644 --- a/lib/lcd.js +++ b/lib/lcd.js @@ -8,8 +8,8 @@ module.exports = function initiateLCD() { // myLcd.write('Hello from PawsIO!'); return function displayMessage(x, y, message) { - // TODO: study repo on way to make the message loop across the screen - myLcd.setCursor(x, y); - myLcd.write(message); - }; + // TODO: study repo on way to make the message loop across the screen + myLcd.setCursor(x, y); + myLcd.write(message); + }; }; diff --git a/main.js b/main.js index 005205a..8a7c58a 100644 --- a/main.js +++ b/main.js @@ -43,6 +43,8 @@ function main() { // if rotary is negative but have payload, check later whether we push let rotarCurr = rotary(); console.log(rotarCurr); + + // split the logic into functions and make the conditional workflow obvious if(rotarCurr < 0) { // if you have data to send, send it and then empty array if(dataPayload.length && !uploading) { @@ -58,7 +60,7 @@ function main() { throw { message: 'no internet connection' }; }; }) - .then(res => { + .then(() => { dataPayload = []; uploading = false; lcd(1,0,'upload success');