A few years ago I was working for a very lean web start up. The team consisted of myself and my father and neither of us could write code. Sure I dabbled a bit in front-end web development but I barely knew enough to be dangerous. Needless to say the engineering work was outsourced to an agency that took a while to ship something that turned out to be pretty far off from what we were expecting. After a few months of frustration I decided to take matters into my own hands.
I took a month off from work (as I knew it) and began to learn the Ruby programming language through a series of online tutorials, trial, and error. Two weeks into my journey I decided to create a prototype of our product using Ruby on Rails. After a few sleepless nights we ended up with a working beta deployed to AWS.
After some research I decided to go with a Redis pub-sub system with Node.js, Express, and Socket.io. I quickly realized this was much more difficult then typing `rails new`. It felt like eternity to build out a single feature in comparison to the rest of the application. Even though this took longer than I expected, I still found myself falling in love with Node.js. Sure it wasn’t as easy as building a Rails app but the performance was incredible. I began to wonder what if the whole app was built with Node.js. What would that look like? How long would it take? Would it even be worth it? Rather than getting second system syndrome and slowing down I moved on, knowing I’d like to focus on Node.js again someday.
Recently I had the opportunity to work on an open-source project and naturally I followed my pipe dream of a Rails-esque framework for Node.js. Granted a few opinionated Node.js frameworks have popped up over the years but none have satisfied me.
Opinionated, Modern, and Fast
Here’s an example of what a Controller looks like:
One thing you’ll notice is there are no “actions”. That’s because you get CRUD actions for free by extending the Lux Controller. Built in actions support parameter sanitization, sorting, filtering, and pagination out of the box. If you need to add a custom action then you just write an async function.
Wouldn’t it be nice if we could start returning values from functions again?
Performance is an essential part of the psychology behind Lux. Routes are stored and accessed in a Map, not an Array. SQL queries never request more data than they need. Clustering is enabled by default and dynamically configured for the device your application is running on. These small but important details show in this basic benchmark.
The title of this post, Not another Node.js framework, is somewhat of a double entendre. If you look at all the great tools we already have out there for Node.js, one could easily think “oh no not another”. In reality though, Lux is not anything like what we currently have available. It’s not another Node.js framework. It’s not meant to replace Express. Express is multi-purpose and un-opinionated. Often times that level of customization is what people are looking for. The same could be said about something like Sails, which allows you to serve static assets and dynamic HTML. I believe Lux fills a void in the Node.js ecosystem and I hope people find a tool like this as useful as I do.
The road to 0.0.1
The core Lux API is reaching stability and includes many of the features that will be available in the first release. We’re sharing it now so that anyone interested can get their hands on it today.