Sunday, November 11, 2012

Node.js and Angular


I started a couple of weeks back looking at MongoDB and Node.js as a means to create simple service application to return json data based on Spatial queries.  The idea that you can query for things that are X miles away from you is pretty compelling and almost normal operation on the web these days.  My current client has a need to do something similar so I set out to investigate MongoDB and Spatial queries.  I found a great example at http://loutilities.wordpress.com/2012/08/10/dogtag-app-in-30-minutes-part-1-node-js-and-mongodb/ which  had all the basics that I was looking for.  It took me about 2 hours to get the service application up and running on my openshift account.

The example uses Sencha touch for the client, which I have had some exposure to, but I really wanted to use a javascript page templating library like Mustache or Angular instead.  After a bit of research I found Angular's bundling of Jasmine and Testacular to be an awesome way to build TDD/BDD into a javascript application from the ground up.  I also like the model/view/controller implementation in Angular and it's straightforward templating language.

I haven't made it to my goal just yet but do have the json service running (Node.js over MongoDB) at https://petfinder-basinc.rhcloud.com/dogtag and I have the angular-seed project cloned and ready to begin web ui development.  So far I have invested about 4 hours and have learned a great deal so far.  

I can't wait to get started on the UI!
  1. Started by setting up node.js server application on my openShift account using this as a guide.
  2. The went thru the angular tutorial/intro at http://docs.angularjs.org/tutorial/step_00
  3. The clone the angular seed project using "git clone https://github.com/angular/angular-seed petfinder-client"
  4. Run the seed project using "node ./scripts/web-server.js"
  5. Review seed app at http://localhost:8000
  6. Review end-to-end test results at http://localhost:8000/test/e2e/runner.html
  7. Next up is to link angular app to petfinder app on openshift.