This was a simple coding dojo project setup for Sask JavaScript to show how easy it is to manage dependencies using node modules, and setup a simple dev environment with node.
This is the final stage of the project, we will be going through each of the steps as a code-along dojo at the meetup.
Steps:
- npm init
- view package.json
- set private true, explain why
- install express with npm
- setup an express simple app.js
- create an index.html
- what is our app going to do?
- consume some photos via the flickr api?
- go create a flickr account, or login to yours and create an "app"
- get a non-commercial api key and secret
- npm install request
- require the request library, which we'll use to make external requests
- setup a proxy to the flickr api to get some pictures back
- restart, and see if it works! (note on addons to view json in browser)
- kind of annoying having to restart the dev server every time, so let's solve that with node-dev
- npm install node-dev --save-dev
- setup a script, npm run-script devserver
- client-side stuff: let's create a little set of modules to deal with the photos
- installing and requiring jquery from within node, to use client-side
- configuring express to use browserify and setup a bundle
- add the bundle to your index.html
- winner :)
- photo.searcher
- photo.viewer
- installing underscore and configuring it for the template function
- noticing that our clientside code isn't being refreshed, because the server needs to restart in order for browserify to rebuild our bundle
- install wach, setup a dev script to do that.
- get things running in our app
- creating a standalone bundle with browserify
- minify with uglify
- setup a script to auto minify for us
This code is made available free of charge. Do what you want with it :)