I received some fantasitc advice from Tom Igoe who lent me his book Making Things Talk and nudged me to explore Node frameworks that make different ports talk to eachother. John Farell (resident ITP) told me about Express, a minimal, flexible Node.js web application which I could use to separate the server and client side portion of my code.
Trials & readings
I got straight into modifying example code from these sources to help me figure out what I need to do,
- Tigoe’s ExpressIntro
- Pg. 386, Making Things Talk (Project 50: Phoning the Thermostat)
- John Farell’s Decapitated Restaurants
- Did the tutorial, Node.js Express Framework Tutorial
- Did a Twilio Tutorial for Node and Express
- Built a Hello World app to get started with Express
- Securing Node.js with Express Middleware
I was having a hard time visualizing the program jump around between functions. How it was structured and how different portions of it interacted between themselves and the browser through protocols was confusing. Terms like REST, require, request, respond etc were getting the better of me.
To get through this I did some side readings, two of the more helpful ones:
- How I explained REST to my wife, explains Difference between REST and HTTP]
- Documentation of Express
Some of the code I knew was relevant to me,
I realized structuring the code so that Node would know where to look for when a path gets called is important and there’s alot more to it than simple callback functions that I’m building.
A separate file needs to be configured for my Node server (HTTP or Express based) that can receive requests from the URL (which will be POST requests from input coming in via a browser page which has text input boxes). The incoming text will have to be routed to different functions.