Using Environment Variables in Node.js with Amazon OpsWorks

I find it hard to believe that I could not find a good article online of how to get env vars working in OpsWorks. I think even more astounding is that it takes a custom recipe to accomplish this end. When you host your app on Heroku, you can easily just do an heroku config:set FOO=bar with the Heroku Toolbelt. In AWS OpsWorks, it’s a little more involved. Let’s see just how.

The MEAN Stack

Maybe you’re familiar with the LAMP stack? Linux, Apache, MySql, PHP. That’s been a pretty common way to serve websites for many years (circa 1998?). But things have changed, technologies have changed, and it’s not 1998 anymore. IE6 is dead, nested tables are dead, and the LAMP stack is the Old and Busted. The New Hotness is the MEAN stack, MongoDB, ExpressJS, AngularJS, and NodeJS. This new stack of technologies is what many new web apps are using these days.

Getting Jenkins ready for Node.js and AngularJS testing

Setting up Jenkins for Node.js + Mocha testing and such Install this stuff Node.js via Nave git clone https://github.com/isaacs/nave.git* ./bin/nave.sh usemain v.0.8.9 Mocha npm install -g mocha ChaiJS npm install -g chai xunit-file (Mocha custom report for Jenkins) npm install -g xunit-file Jshint npm install -g jshint Nock npm install -g nock Supertest npm install -g supertest Testacular npm install -g testacular PhantomJS npm install -g phantomjs Here is a handy script that will install v0.

Installing Node.js on CentOS using Nave

So I needed to install Node.js on CentOS, but I was hard pressed to find a yum repo that was up to date. Then I stumbled upon Nave. This is really easy. It’s just a bash script that you run to install node and npm. # Get the nave.sh shell script wget https://raw.github.com/isaacs/nave/master/nave.sh chmod +x nave.sh ./nave.sh usemain 0.8.8 node -v # Will print # v0.8.8 Life could not be easier

Metamorphosis from PHP to JavaScript

The following is account of why I prefer writing programs in JavaScript over PHP. I have well over 10 years of programming experience in PHP. I’ve written everything from a simple one page PHP program, to a complex Zend Framework apps, to you name it, I’ve coded it in PHP (even stuff I know I should have not done in PHP). You Always Play To Your Strengths, if PHP is your strength, that’s going to be your game

MongooseJS and the problem with adding new properties

My setup is easy. Node.js, ExpressJS, MongooseJS. The Problem I was getting a list of objects from the MongoDB. Like this // Find all items where owner in following array Thing.find() .where('owner').in(following) .populate('owner') .populate('comments.userId') .sort('-updatedOn') .limit(20) .exec(callback); In the callback I was assigning the results to res.locals.things for use in another middleware function. In another middleware function I tried this // Extend thing[i] with a new property called newProperty for var i=0; i < res.