So two posts ago I documented my first foray into nodeJS. The result was a simple HTTP server that served one line of static HTML. All I really accomplished was to prove to myself that nodeJS was installed correctly, I could copy/paste six lines of code, and that the copied code would actually create a working HTTP server. Of course I was ecstatic when it worked… a bit giddy, even!
With the aroma (stench?) of success still lingering I plunged in again, this time following along with Ryan Dahl‘s 2009 JSConf presentation. Of course, nodeJS has changed a lot in the last 14 months so getting his presentation examples to work took a bit more than copy/paste skills. It made for an excellent playground in which to learn nodeJS basics.
Having finished the video and finding success in getting each of Ryan’s demos to work in the latest nodeJS (v0.3.6-pre) I ended up with an excellent beginner’s showcase: 7 example nodeJS scripts showing off non-blocking, long-poll, file IO, streaming IO, TCP servers and HTTP servers. Each one of these scripts can be run with the simple command “node <script_name>”. The gist of my experience (sorry… I couldn’t resist) can be found below: well, at least 2 of the seven examples. You’ll have to visit this gist on github if you’re interested in seeing all 7 examples along with comments containing directions and expected response details for each script.
My next step will be to drive nodeJS services through tests, ideally using the excellent BDD framework… Jasmine!