Giter Club home page Giter Club logo

lametric-air-now's Introduction

Build Status Codacy Badge GitHub issues license David David

lametric-air-now

Air Now air quality reports for LaMetric using the Air Now API. Add it to your LaMetric at http://apps.lametric.com/apps/air_quality_now/439

Reason

My wife is obsessed with the air quality reports, i tried to put this together a while back but LaMetric had not yet added config params to their UIs and the geo-ip thing seemed to tiring to attempt.

Tech

I wanted to do a Travis-CI continuous deployment to heroku deal for this, and it seemed like node.js with express was the easiest way to do this, so that's what i did.

Development

Once i decided on node & express i had been meaning to try out gulp cause i loved SBT so much, so found https://github.com/petecoop/generator-express to build a nice gulp based project, especially since it offered easy CoffeeScript support and i had been hubot'ing as of late.

No idea what all these templating engines are, Jade looked like a lot, i've used mustache and handlebars so wanted to try something new to compare. Swig looked a lot like handlebars. Marko seemed interesting with it's "concise" syntax so went with that.

Installed mocha npm install -g mocha Installed gulp npm install -g gulp

Found the node.js plugin for intellij...but not sure that's what i want.

Tried running gulp

/lametric-air-now/node_modules/coffee-script/lib/coffee-script/coffee-script.js:234
      throw helpers.updateSyntaxError(err, stripped, filename);
      ^

/lametric-air-now/app/controllers/home.coffee:9:1: error: unexpected indentation
    indexTemplate.render
^^^^

Mucked with that quite a bit to get it to compile and show some stuff

started reading https://docs.travis-ci.com/user/languages/javascript-with-nodejs and setup a .travis.yml, but i don't have any tests and don't even know what those would look like...

switched over to heroku docs at https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction

Downloaded the tool belt and created a new app..but it failed

stumbled upon this https://devcenter.heroku.com/articles/github-integration will need to come back to that

pretty sure i failed cause of port. Need to have a heroku mode.

that wasn't it, heroku logs output

2016-06-04T22:38:43.616062+00:00 heroku[web.1]: State changed from crashed to starting
2016-06-04T22:38:44.952440+00:00 heroku[web.1]: Starting process with command `npm start`
2016-06-04T22:38:46.836586+00:00 app[web.1]: > [email protected] start /app
2016-06-04T22:38:46.913015+00:00 app[web.1]: Error: Cannot find module 'coffee-script/register'
2016-06-04T22:38:46.913014+00:00 app[web.1]:
2016-06-04T22:38:46.836572+00:00 app[web.1]:
2016-06-04T22:38:46.836591+00:00 app[web.1]: > node app.js
2016-06-04T22:38:46.913016+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:339:15)
2016-06-04T22:38:46.836592+00:00 app[web.1]:
2016-06-04T22:38:46.912983+00:00 app[web.1]: module.js:341
2016-06-04T22:38:46.913012+00:00 app[web.1]:     throw err;
2016-06-04T22:38:46.913013+00:00 app[web.1]:     ^
2016-06-04T22:38:46.913017+00:00 app[web.1]:     at Function.Module._load (module.js:290:25)
2016-06-04T22:38:46.913017+00:00 app[web.1]:     at Module.require (module.js:367:17)
2016-06-04T22:38:46.913018+00:00 app[web.1]:     at require (internal/module.js:20:19)
2016-06-04T22:38:46.913021+00:00 app[web.1]:     at Function.Module.runMain (module.js:447:10)
2016-06-04T22:38:46.918889+00:00 app[web.1]:
2016-06-04T22:38:46.926196+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-06-04T22:38:46.925807+00:00 app[web.1]: npm ERR! Linux 3.13.0-85-generic
2016-06-04T22:38:46.927316+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2016-06-04T22:38:46.926429+00:00 app[web.1]: npm ERR! node v5.11.1
2016-06-04T22:38:46.927494+00:00 app[web.1]: npm ERR! [email protected] start: `node app.js`
2016-06-04T22:38:46.913018+00:00 app[web.1]:     at Object.<anonymous> (/app/app.js:1:63)
2016-06-04T22:38:46.913019+00:00 app[web.1]:     at Module._compile (module.js:413:34)
2016-06-04T22:38:46.913019+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:422:10)
2016-06-04T22:38:46.913020+00:00 app[web.1]:     at Module.load (module.js:357:32)
2016-06-04T22:38:46.913021+00:00 app[web.1]:     at Function.Module._load (module.js:314:12)
2016-06-04T22:38:46.926980+00:00 app[web.1]: npm ERR! npm  v3.8.6
2016-06-04T22:38:46.927997+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script 'node app.js'.
2016-06-04T22:38:46.928165+00:00 app[web.1]: npm ERR! Make sure you have the latest version of node.js and npm installed.
2016-06-04T22:38:46.927657+00:00 app[web.1]: npm ERR! Exit status 1
2016-06-04T22:38:46.927833+00:00 app[web.1]: npm ERR!
2016-06-04T22:38:46.929129+00:00 app[web.1]: npm ERR!     npm bugs lametric-air-now
2016-06-04T22:38:46.929609+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2016-06-04T22:38:46.932939+00:00 app[web.1]:
2016-06-04T22:38:46.933161+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2016-06-04T22:38:46.928491+00:00 app[web.1]: npm ERR! not with npm itself.
2016-06-04T22:38:46.928969+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with:
2016-06-04T22:38:46.928817+00:00 app[web.1]: npm ERR!     node app.js
2016-06-04T22:38:46.928649+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2016-06-04T22:38:46.928330+00:00 app[web.1]: npm ERR! If you do, this is most likely a problem with the lametric-air-now package,
2016-06-04T22:38:46.929287+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via:
2016-06-04T22:38:46.929450+00:00 app[web.1]: npm ERR!     npm owner ls lametric-air-now
2016-06-04T22:38:46.933316+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2016-06-04T22:38:47.666782+00:00 heroku[web.1]: Process exited with status 1
2016-06-04T22:38:47.681379+00:00 heroku[web.1]: State changed from starting to crashed

found this http://stackoverflow.com/questions/6356267/can-i-run-coffeescript-in-heroku which didn't directly answer my question, but made me just move coffee to my dependnecies out of devDependencies and that got it kinda working.

The next problem was port, and i had to modify the config.coffee to have a heroku envvironment config and switch port logic to port: process.env.PORT || 3000. i fond that port via this answer http://stackoverflow.com/a/18790034/442773 which let me know PORT was an env variable. finally i had to run heroku config:set NODE_ENV=heroku so on startup it would use my heroku config

After that it went pretty smooth. heroku has come a long way in 2 years. The have a deploy concept where they just auto deploy a commit, and can even tie to to the github status api such that they only deploy if the commit passes the status...but beyond that they kinda formalized the whoel dream of having PRs spin up new instances for testing. They fit it in to this thing called pipelines which let you promote an app from dev->stage->prod but it's way more configurable than that. The dev is by default what they call Review Apps and they really did it smart. PR's get deployed (and they can be tied to status api too) and you can run a setup file and a tear down file, they'll auto kill inactive nodes after 5 days optionally, and it can copy over config vars from a "parent" app or set them specifically or randomly: IE you can define your prod config over. Now they say that's not so good because anyone coudl write code, open a PR and output keys like mad..but it's still pretty rad. They also set some env vars to let your app know that it IS A review app so it could act tricky..maybe.

In summary: you don't deploy to heroku through travis-ci anymore, that's so last year. (YAY).

lametric-air-now's People

Contributors

drdamour avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

amirtoole

lametric-air-now's Issues

03801

03801 doesn't seem to be able to be retrieved. I see the project has not been touched in a while. Are you still working on it?

Deal with partial data

If the current request fails but the forecast succeeds, we should still return data. and vice versa

Add caching

from https://docs.airnowapi.org/faq#caching

In general, air quality observations are updated once per hour and forecasts are issued once per day. Therefore, we recommend users cache daily or hourly air quality observation or forecast data retrieved via web services. For example, air quality observations for the previous hour are generally available between 10 and 30 minutes past the hour.

Allow user to pick measurement type

O3 is just one type, there are others apparently like PM2.5 and PM10. Maybe a drop down?

[{
    "DateObserved": "2016-06-04 ",
    "HourObserved": 23,
    "LocalTimeZone": "MST",
    "ReportingArea": "Boise",
    "StateCode": "ID",
    "Latitude": 43.6361,
    "Longitude": -116.2033,
    "ParameterName": "O3",
    "AQI": 28,
    "Category": {
        "Number": 1,
        "Name": "Good"
    }
}, {
    "DateObserved": "2016-06-04 ",
    "HourObserved": 23,
    "LocalTimeZone": "MST",
    "ReportingArea": "Boise",
    "StateCode": "ID",
    "Latitude": 43.6361,
    "Longitude": -116.2033,
    "ParameterName": "PM2.5",
    "AQI": 77,
    "Category": {
        "Number": 2,
        "Name": "Moderate"
    }
}, {
    "DateObserved": "2016-06-04 ",
    "HourObserved": 23,
    "LocalTimeZone": "MST",
    "ReportingArea": "Boise",
    "StateCode": "ID",
    "Latitude": 43.6361,
    "Longitude": -116.2033,
    "ParameterName": "PM10",
    "AQI": 33,
    "Category": {
        "Number": 1,
        "Name": "Good"
    }
}]

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.