I am a Ruby on Rails developer with extensive experience in Ember.js - so it was about time to try server JS!
A few weeks ago I bumped into the following situation - I needed to use a company-shared (but very rarely used) account on GitHub that has two factor authentication enabled. It turned out that the physical phone was in our office and every time I needed to sign in to the account in incognito mode I had to ask our office team on Slack to send me the code. I didn’t like this and after brainstorming with couple of teammates I decided to make an app to fix it!. Let’s create a shared Twilio phone number that will be set on our shared 2FA account and store all the messages in the app, then expose these messages to users that sign in with a Google account through our netguru.pl domain and simulateneously post a notification to Slack that some new message has arrived on our Twilio number.
I was not convinced that this solution is good for us as it decreases the security level. To add an upside in case the app ends up not finding company-wide use, I decided to write it in node.js so at least I got to learn something new along the way.
First meeting with express.js
My first impression about express.js was surprise. There are tutorials available, but most of them strongly highlight that this is only one option that you use can achieve your goals. It’s a little bit confusing at the beginning in comparison to Rails, where everything is very straightforward from the start. However, I eventually came to the conclusion that coding in node.js is similar to Sinatra - take just the low level requests and response objects and do everything your way. Inspiring, actually.
Development and resources
I started with two tutorials that I found on Pluralsight - here and here. It took me a few hours to go through them, but I reused most of concepts that I learnt in my application. I didn’t like the lack of ES6, but your first experience with a technology is not the time for experimenting.
What I really liked about this experience was the functional programming. I didn’t use any helpers, globals or strange methods. Everything just comes as an argument in your callback function, so I found the learning process nice and straightforward. I read the API of express.js and knew exactly what is and what is not available in the functions that I am working with.
Are you working with node.js everyday? Would you like to share your opinions?