Eric Bergman-Terrell's Blog

This Website is Now Powered by Node.js and Express
August 27, 2015

About three years ago, Ruby on Rails was all the rage. In order to familiarize myself with it, I took the step of converting this website to Ruby on Rails. It was previously implemented in ASP.NET. I was frankly unimpressed with Rails. The Ruby language was nothing special, and I found the integration between the Rails commands and the database to be annoying, rather than helpful.

Recently I got an email from Google announcing the imminent deprecation of their old captcha API. But I could not force myself to even find an updated captcha gem and get it working. Now the excitement that was formerly focused on Ruby on Rails has largely shifted to Node.js. So I decided to "kick the tires" of Node.js, by again converting the website.

As of about a week ago, this website is powered by Node.js. I'm using the Express web framework, and a mysql database. I'm using the WebStorm development environment. Many Node.js developers are using MongoDB but, my data was already in mysql, and I know SQL pretty well. The website is hosted by A2 Hosting. A2 does a pretty good job, and at least for now, I am getting very good performance and support, especially considering the small price that they charge. I'm on the "Swift" hosting plan, in case you're curious.

Here are the major components that were used in this website's Node.js / Express incarnation:

.
ComponentUsed For
foreverBy default, your Node.js app will stop right after the first uncaught exception occurs. In this situation, forever will quickly restart my web application.
passport, passport-localPassport provides user authentication for my "admin" user, who has access to ericbt.com's administrative functions.
ejs, ejs-localsExpress allows one to use whatever template engine one wants. I started out with Handlebars and abandoned it after I realized that the template language was too limited for my purposes. It can be tedious inserting Javascript code inside of ejs templates, but at least the Javascript programming language is sufficiently powerful to handle basic content formatting issues. ejs-locals provide layouts, which are useful for imposing a standard look-and-feel on multiple pages.
emailjsI use emailjs to generate email notifications to me. (This website does not send emails to anyone else).
formidableParsing form data for image uploads
morganHTTP Request Logging
log4jsLogging
mysqlDatabase queries
asyncWhen I implemented pages that required multiple data items, I found myself writing deeply nested code that didn't exploit concurrency opportunities. async allowed me to replace my code with more elegant, readable, and efficient code.
fs-extraFile manipulation
line-readerLog file filtering
pretty-dataXML pretty-printing
bootstrapHTML styling, navigation bar, pagination, image styling, "glyphicons"
yuicompressor,
html-minifier
Minification of CSS, Javascript, and HTML content
compressionGzip compression of website content
Google reCAPTCHA serviceReducing nuisance data posted to public forms.
heapdumpMemory leak troubleshooting

I was really surprised by two things during this conversion effort:

  1. It was substantially easier than I expected.
  2. I actually enjoy Node.js and Javascript development.

Surprise #1 was due to the fact that Node.js and Express don't get in the say of rapid development. It is a real pleasure to implement a new page, or new feature, in minutes rather than hours.

As for surprise #2, I've never been a big fan of Javascript, but I suppose taking a class previously in the Scala programming language made me more receptive to the functional aspects of Javascript. And WebStorm caught many of my Javascript errors before runtime, offered usable "intellisense", and a good debugger for finding and fixing issues that made it all the way to runtime.

play with new technologies

Take a little time each day to play, even if it's just with new software development technologies.

Keywords: Node.js, node, Express, captcha, ASP.NET, Ruby on Rails, Rails, mysql, SQL, MongoDB, A2 Hosting, forever, ejs, ejs-locals, passport, passport-local, authentication, authorization, template engine, WebStorm, fs-extra, Javascript, Scala, functional programming, Scala, line-reader, log parsing, bootstrap, navbar, pagination, glyphicons, xml, xml pretty-printing, minification, compression, gzip, morgan, logging, heapdump

Reader Comments

Comment on this Blog Post

Recent Posts

TitleDate
Java Programming Tip: SWT Photo Frame ProgramOctober 31, 2016
Vault 3 (Desktop) Version 1.63 ReleasedSeptember 9, 2016
"Compliance with Court Orders Act of 2016"April 9, 2016
Disable "Visual Voicemail" on Android / T-MobileJanuary 17, 2016
IPv6 HumorDecember 10, 2015
Java Programming Tip: Specify the JVM time zoneDecember 7, 2015
Node.js / Express Programming Tip: Detect and Fix Memory LeaksOctober 27, 2015