Node.js may be several years old now, but it's still in the spring of its life. The options are multiplying, as everyone experiments with new and better ways to deliver information from the platform. These efforts translate into dozens of frameworks for Node.js enthusiasts and newbies to explore, and new growth everywhere.
What follows are a few of the most prominent frameworks that have caught our eye. They make it simpler to build a complex website filled with pages, panels, fragments, and more. If you're starting a new project, try out a few of these to quickly build on all the prior work and experience that has been bundled into these projects.
Express is a very thin shell that offers a framework for lightweight processing of requests. It maps the URL to a template and fills in the values with data from a generic data store. The standard template engine is Consolidate, but the pattern is simple enough that most template engines will work quite well.
The Express team promises that MySpace is trying to upgrade its hipness score by building the next version in Express. If you don't remember MySpace, ask your grandparents. They may still have an account.
Express is distributed under the MIT license from GitHub.
The team that built Express decided to move on and build the next generation with a new, telescoping call stack called Koa.js that's designed to let you add new features to the call and response handshake. You start by writing a bit of code to handle the request, but then you can customize anything along the path. The middleware that handles all of the telemetry and error handling are open for your changes. There are also dozens of plug-in packages that add compression, caching, JSON encoding, and more to the stack.
The image above shows some of the Jade markup used by one of the templating libraries bundled with Koa.
Koa is distributed under the MIT license from GitHub.
The Total.js stack is designed to automate as much as possible. You start with a markup template for the HTML and CSS, and Total then compiles it into raw code and compresses it for delivery. In a sense, Total is one big compiler of websites masquerading as a framework.
The image above shows an example built to support a sushi bar website with ordering and more.
Total is distributed under the MIT license from GitHub.
One of the points of Node.js is to use the same language in the browser and the server. Derby.js takes this to the extreme by trying to run the same code in both and synchronizing the results. Then it tosses in template rendering, packaging, and some MVC to simplify the process. You don't need to worry about, say, compiling your CSS because Derby has it integrated.
The image above shows a basic To Do example distributed with the code.
Derby is distributed under the MIT License at GitHub.
Meteor.js is a real-time application designed to build Web apps that constantly synchronize with the server. Your changes to templates and data flow from the server to the browser automatically. The redrawing and the updating are handled directly by the underlying framework. This works, by the way, in both directions. Your browser code can make changes or write data as if the database is right there. The synchronization happens in the background.
The image above shows an app for synchronizing the work of emergency first responders built in Meteor.
Not every application requires full support for a browser. Restify is one of the server-side frameworks designed to serve up data and only data through an API. You fire it up and out comes JSON to everyone who shows up.
Restify places special emphasis on debugging and profiling so that you can drill down and optimize the performance of your server. DTrace is well-integrated and supported to make it possible to watch what happens and when it might go wrong.
The image above shows an audit packet saved from a debugging session.
Restify is available from GitHub under a very basic license that requires little except a notice of copyright.
You can build full websites with the Hapi framework, but many who use Hapi focus on building services that pull data from the background and deliver it quickly and efficiently. Each server is only a collection of maps between URL paths and functions that generate answers, and these routes are configured using the Hapi API rather than being baked into new code. The Hapi community supports a wide variety of plug-ins that tackle many of the chores of authentication and security necessary for building services.
The screenshot above shows a few of the standardized errors that are formalized by the Boom plug-in, which provides a set of utilities to help users better understand what has gone wrong when an HTTP error arises.
Hapi is available with a license requiring basic attribution from GitHub.
If you need to create a business-grade custom Web application, the Sails.js MVC framework will handle many of your app’s core tasks while remaining flexible enough to work with other tools. It is both “front-end agnostic” and ready to work with “any database,” according to the maintainers. The magic in between is largely automated, at least if you want to work with the standard REST API generated by the framework. If you’ve enjoyed the Ruby philosophy of convention and MVC separation, everything will be familiar to you -- and ready to go.
The illustration above shows the basic directory structure of a Sails app.
Sails is available under the MIT license from GitHub.
Most of the work of creating an API can be automated. Once you know the data model, building the tools for editing the data is largely an exercise. StrongLoop automates much of this and adds connectors for most of the big data stores like Oracle, MySQL, and MongoDB. To add more flexibility, they support either dynamic data models that evolve with time or static models with a fixed schema. It's your choice. There's also a ready-made security layer with access control lists and some good mobile services. All of this is built on top of Express so that you start with all of the Express feature set.
You can see StrongLoop's API explorer in the image above.
StrongLoop is available with either a hybrid open source license for test projects or under a subscription that includes support and more connectors to high-end databases like Oracle. Code is available at GitHub.
Many frameworks aim to deliver high-end support for full-featured users running browsers and interacting via JSON. ActionHero does that but also works on a lower-level, communicating directly with the TCP with wire protocols. It's great if you need something simpler than JSON. This can be quite useful if you want to send out raw files too because ActionHero delivers like a CDN without forcing you to run Apache or Nginx.
The image above shows ActionHero's stack with the sections devoted to handling the different actions and its connection to Redis.
ActionHero is available under the Apache license from GitHub.
Express and MongoDB are key components of the Node.js stack, but you need to knit them together and add a bit more functionality to actually deliver your message to the world. Keystone.js is meant to join Express and MongoDB together to complete the arch, in this case a content management system. This is now a bit easier thanks to Keystone’s scaffold-building service called Yeoman, which fills out the files and installs everything you might need to run a blog or post other content.
The image above shows a corner of an image-sharing demonstration page built using Yeoman and Keystone.
Keystone is available under the MIT license from GitHub.
The image above shows how an old SQL query can be rewritten to work in the modern world of Node.
Sequelize’s source code is released under a basic attribution license from GitHub.
Mean isn’t really a framework for Node.js; it’s a collection of frameworks and technologies that are pre-optimized to play well together, under the acronym MEAN, which stands for MongoDB, Express, Angular, and Node. Each component is among the most popular parts of the Node ecosystem on their own; together, they’re even easier to use.
The image above shows how the Node package manager will install the parts and a new command, mean, for developing applications.
The parts that make up Mean are available under their own licenses from their own repositories.