Node.js libraries

Web framework

We chose Express minimalistic web framework, because:

  • It’s the most popular choice.
  • It has a wide range of extensions and middlewares.
  • It is fast.
  • It is minimalistic and can be configured based on our needs.

We use it for both server-rendered and Single-Page applications.

Server-rendered applications

We use standard Express stack with middlewares for server-side view rendering, sessions, etc. Assets (JavaScript files, Stylesheets, Images, etc.) are handled in a similar way to what Rails Asset Pipeline does with help of webpack.

Single-Page applications

For Single-Page applications, we write RESTful APIs or use GraphQL, depending on project requirements.

RESTful APIs

Use standard Express stack to render JSON or any other format, such as XML.

GraphQL

We use Facebook Relay with Express integration. Check Node.js architecture for details how to organize code. For integration with Sequelize use graphql-sequelize, a library which provides helper functions for automatic resolvers, combining queries, pagination, etc. For Bookshelf we have our own helpers, which behave identically to what graphql-sequelize offers.

ORM

We prefer to use ORM over raw SQL queries because it increases productivity, reduces code repetition, increases security and many other benefits. We have chosen two more popular and feature-rich ORMs, Sequelize and Bookshelf, and use one of them depending on project requirements and ORMs activity and popularity.

Bookshelf is a feature rich and mature ORM, however, at the time of writing development has stalled. Its query interface is more comfortable and powerful to what Sequelize has to offer. However, Sequelize is more actively maintained and more popular.