The complete guide to Node.js frameworks

A quick tour of the best MVC frameworks, REST API frameworks, full-stack frameworks, and other handy libraries for Node.js

1 2 3 Page 3
Page 3 of 3

SocketCluster supports both direct client-server communication (like Socket.io) and group communication via publish and subscribe channels. It is designed to scale both vertically across multiple CPU cores and horizontally across multiple instances.

SocketStream

SocketStream is a framework for real-time web apps that features WebSocket communication between client and server. SocketStream sends all of the HTML, CSS, and client-side code that your app needs the first time a user visits your site, all automatically compressed when run in production mode.

From then on all application data is sent and received via the WebSocket (or WebSocket fallbacks) established when the client connects. Normally this will be in JSON RPC format, but SocketStream allows you to use different request responders (message handlers) depending upon the task at hand.

SocketStream plug-ins range from code formatters, to client-side framework extensions, to behavior-driven development plug-ins. SocketStream is good for building real-time apps, but not so good for building websites that need persistent URLs for SEO purposes.

REST API frameworks for Node.js

ActionHero

ActionHero is a multi-transport API server with integrated cluster capabilities and delayed tasks. The goal of ActionHero is to create an easy-to-use toolkit for making reusable and scalable APIs. Clients connected to an ActionHero server can consume the API, consume static content, and communicate with each other. ActionHero is cluster-ready, with built-in support for background tasks, zero-downtime deploys, and more.

ActionHero supports HTTP/S web clients, TCP (Telnet) and TLS socket clients, and HTTP/S WebSocket clients out of the box. ActionHero servers can process both requests and tasks (i.e. delayed actions like sending email or other background jobs). ActionHero servers can also run in a cluster (on the same or multiple machines) to work in concert to handle your load.

The ActionHero tutorial creates a blogging API and site, a chat room, and a custom server that sends a filtered Twitter stream to the chat room.

Frisby

Frisby is a REST API testing framework built on Node.js and Jasmine. Frisby tests start with frisby.create followed by one of get, post, put, delete, or head, and ending with toss to generate the resulting Jasmine spec test. Frisby has many built-in test helpers such as expectStatus to easily test HTTP status codes, expectJSON to test expected JSON keys and values, and expectJSONTypes to test JSON value types.

Restify

Restify is a Node.js module created specifically to enable you to build correct REST web services. It intentionally borrows heavily from Express as that is more or less the de facto API for writing web applications on top of Node.js. However, Restify is not intended to create browser applications, so it lacks the templating and rendering support built into Express. Rather the goal is to give you absolute control over interactions with HTTP and full observability into the latency and characteristics of your applications.

LoopBack

LoopBack is a highly extensible Node.js framework that enables you to create dynamic end-to-end REST APIs with little or no coding. It can access data from Oracle, MySQL, PostgreSQL, SQL Server, MongoDB, SOAP, and other REST APIs, and can incorporate model relationships and access controls for complex APIs. LoopBack lets you use built-in push, geolocation, and file services for mobile apps, and easily create client apps using Android, iOS, and Angular SDKs.

LoopBack consists of a library of Node.js modules, Yeoman generators for scaffolding applications, client SDKs for iOS, Android, and web clients, and a command-line tool to create applications, models, data sources, and so on.

IBM and the StrongLoop team behind LoopBack say they are committed to maintaining and improving the LoopBack open source project. Building on LoopBack’s success as an open source Node.js framework, IBM API Connect provides the newest tools to use with LoopBack projects, and includes a free version, API Connect Essentials, especially for developers.

Fortune.js

Fortune.js is a database abstraction layer that implements features at the application level for Node.js and web browsers. It provides a common interface for databases, as well as relationships, inverse updates, and referential integrity, which are built upon assumptions in the data model.

Fortune.js is particularly useful for maintaining bi-directional relationships in any database, sharing the same data models on the server and client, and building applications that need storage options to be portable.

By default, the data is persisted in memory (and in IndexedDB for the browser). There are adapters for databases such as MongoDB, Postgres, and NeDB (an embedded document data store with an API that is mostly compatible with MongoDB). Additional features such as networking (HTTP, WebSockets), the database adapters, and serialization formats are listed in the Fortune.js plug-ins page.

Nest

Nest is a web framework for Node.js that helps you to build efficient, scalable applications. It is built with TypeScript (but it’s also compatible with plain ES6) and combines concepts from object-oriented programming and functional programming. Nest uses Express and Socket.io, and has its own IoC (inversion of control) container. Nest syntax is similar to Angular in its use of components and decorators, except that Nest routes have REST endpoints, as is appropriate for an API-based application, as opposed to a website.

Moleculer

Moleculer is a high-performance, fault-tolerant, extensible microservices framework for Node.js. The developers’ own benchmarks, which you can download and repeat, show Moleculer capable of much higher request rates than, for example, Seneca, both for local in-memory and remote NATS Server scenarios. Whether the framework overhead is significant in the real world will depend on the response time of the services themselves.

The Moleculer framework uses a service broker and service pattern. The broker has built-in load balancing and a circuit breaker for fault tolerance. Features include service mix-ins, built-in caching (memory, Redis), pluggable transporters (NATS, MQTT, Redis), pluggable serializers (JSON, Avro, MsgPack, Protocol Buffer), load balanced requests (round-robin, random), auto-discovery services, parameter validation with fastest-validator, distributed timeout handling with fallback response, health monitoring, service versioning, and an official API gateway module.  

Other libraries for Node.js

Connect

Connect is an extensible HTTP server framework for Node.js using “plug-ins” known as middleware. Connect’s original author was TJ Holowaychuk, who was also the creator of Express, Koa, and many other projects. Express and Connect are (or were at one time) maintained by the same development team.

Connect is a simple way to glue together middleware to handle requests: 

var app =connect();
app.use(functionmiddleware1(req, res, next) {
  // middleware 1
  next();
});
app.use(functionmiddleware2(req, res, next) {
  // middleware 2
  next();
});
var server = app.listen(port);

Cylon.js

Cylon.js is a JavaScript framework for robotics, physical computing, and the Internet of Things, with support for 43 platforms including single-board computers such as Arduino and Raspberry Pi, drones such as the Bebop, bots such as Sphero and MiP, and transports such as MQTT. Cylon makes it easy to command robots and devices.

Cylon.js can be run directly in-browser using the Browserify NPM module. You can also run it from within a Chrome connected app or a PhoneGap mobile app.

nodejs cylon The Hybrid Group

Kraken

Kraken, a PayPal open source project, is a secure and scalable layer that extends Express by providing structure and convention, much like Locomotive. Though Kraken is the main pillar of its framework, the following modules can also be used independently: Lusca (security), Kappa (NPM Proxy), Makara (LinkedIn Dust.js i18N), and Adaro (LinkedIn Dust.js Templating).

Kraken relies on yo to generate projects, as shown in the screen shot below. Like Locomotive, it organizes its projects into conventional Rails-like directories including models, controllers, and config. As generated, Kraken ties into Express as standard middleware, defined as an app which then has its app.use() and app.listen() methods called. Each route in a Kraken server lives in its own file in the controllers folder.

nodejs kraken IDG

 

Sequelize

Sequelize is a promise-based Node.js ORM for Postgres, MySQL, SQLite, and Microsoft SQL Server. It features transaction support; one-to-one, one-to-n, and n-to-m relations with foreign keys; read replication; connection pooling; and more.

Sequelize is the main class, loaded with require(). The Model class represents a table in the database. Instances of the Model class represent database rows. The transaction object is used to identify a running transaction. It is created by calling Sequelize.transaction(). To run a query under a transaction, you should pass the transaction in the options object.

Finder methods are intended to query data from the database. They do not return plain objects but instead return Model instances. The Sequelize CLI can perform common database chores such as migration, seeding, and initialization. 

Wintersmith

Wintersmith is a simple yet flexible static site generator. It takes contents (Markdown, Less, scripts, etc.), transforms them using plug-ins, and outputs a static website (HTML, CSS, images, etc.) that you can host anywhere.

Wintersmith ships with plug-ins for Markdown and Jade templates, and it has a wide selection of other plug-ins for content generation and other types of templates.

Copyright © 2017 IDG Communications, Inc.

1 2 3 Page 3
Page 3 of 3