All Case Studies Design Development Interviews Our Way Project Management

Introducing Twilio Scrapper - Writing Apps in node.js After Ruby

In this blogpost I’d like to share with you my impressions of writing an experimental app in Node.js with no experience in server-side JavaScript. I am a Ruby on Rails developer with extensive experience in Ember.js - so it was about time to try server JS!

Background

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.

I find JavaScript extremely exciting when working with Ember.js, and I must say that developing an app in pure JavaScript was very similar. Functional programming and the prototypal inheritance that is present in the frontend application was basically everywhere in the code and strengthened my confidence that knowledge about JavaScript fundamentals is obligatory for every developer - both frontend and backend. And last, but not least - this app is basically a couple of files and very few lines of code, it has an extremely easy setup and it works!

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.

Conclusion

As a guy who always thought about Rails in terms of backed, it was fun to try node.js for a couple of days. I will certainly try to extend my experience in that area and eventually code something bigger. If you would like to see the code of Twilio Scrapper, check it out on Github. Also, I confirmed the statement that is very often repeated nowadays - JavaScript is both backend and frontend and will be around for a long time.

Are you working with node.js everyday? Would you like to share your opinions?

I have also published the blogpost about my rock-paper-scissors Slack bot written in node.js. It’s not an application in express.js, but is very funny and I’m still improving it, check it out!

Why it is impossible to hire quality engineers in London and how to deal with it
Scaling SaaS
READ ALSO FROM Node.js
Read also
Need a successful project?
Estimate project or contact us