Time is Your Enemy is Your Friend

Stories of Rehabbing an Old Home I haven’t posted about the house in a while.  Part of it is because I’m lazy.  Part because it’s summer and there are other things to do.  Part because I’ve been writing about tech stuff (for fun and profit!).  But really, it’s because there have been so many home projects going on, and ALL of them take way more time, energy, effort, and money than planned.  On the other hand, things are happening so fast it’s hard to say how they happened at all. For instance, I bought a kiln.  I was planning on buying one to get back into pottery.  But that meant like next year, or maybe two years.  You know, when I’m “ready” for one.  Instead, I found one for a great price (a bargain I won’t be able to find next year, or maybe two years…) this week.  So, an eventual thing turned into a now thing. One of the things I heard early on- and believed in my head at least- was that you don’t have to do everything right now.  Do the important things in the order they come, and the rest can happen when it happens.  On my move-in day, a friend offered to help me start stripping paint, but I had to decline because the project at hand was sorting out the weird plumbing issues, and the holes in the roof, and the missing doors. Believing that advice in my heart took a while though.  It took about 6 months of perpetual grinding on projects before I stopped myself.  There must come a time for...

Node.js and REST


Warning: file_get_contents(https://bitbucket.org/danielclouse/why-rest/raw/5139a934576196a20b34d522340ce7490c36a4d5/sailsAPI/api/controllers/FooController.js?at=master): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/public/wp-content/plugins/wp-git-embed/wp-git-embed.php on line 99
This is the second in a multipart series about REST APIs. Learning to REST Why REST Node.js and REST Even Microsoft Takes a REST (coming soon!) Getting REST with Angular (coming soon!) CORS and REST Across Domains In the last blog post I front end that consumes a simple REST API endpoint and utilizes http verbs in an idiomatic way.  In this post we will build a simple back end using Node.js and some tools.  Remember, the objective isn’t to to become a master at Node.js, but to understand what makes a REST API powerful and flexible. Preparation For the sake of brevity, I’ll be using the Sails.js framework since it does a lot of the work for me, and lowers the bar (considerably) for prototyping a REST API. First you’ll need to install Node.js.  They have great instructions on their website and support most operating systems.  Node comes pre-packaged with the Node Package Manager, or NPM for short, which is an indispensable tool for managing dependencies in whatever software you write. Next, you’ll need to install Sails.js.  To do this you’ll use NPM with the command: npm install sails -g If you’re on a Mac or Linux system, you might need administrator privileges to do this, so the command is: sudo npm install sails -g Next up, tell Sails to create a new application.  For this demonstration, we can call it “sailsAPI”: sails new sailsAPI Sails created a folder and a Node application for us.  Navigate into that folder, then tell Sails we want to create the scaffolding for a new model and controller called “foo”: cd sailsAPI sails generate api...