NodeJS Frameworks For Developing Web Applications
NodeJS is JavaScript for the server side. This allows the reuse of the myriad of JavaScript libraries already written for the browser. If you know JavaScript you already know how to write code for NodeJS.
NodeJS Web Applications – Where To Start?
Well, the easiest way is to use one of the NodeJS Frameworks that are already available. We will take a look at a few of them that caught my eye. These are full stack web application frameworks. This means that they address all the requirements of developing a web application.
The following NodeJS frameworks came up a lot during my research for a new project I’m working on. The project is a total rewrite of an enterprise Java application currently running on a portal technology called Liferay.
The NodeJS frameworks I selected are:
So, let’s begin.
SailsJS
First of all, from the list of NodeJS frameworks in this article I have to admit that I’ve worked most with SailsJS.
I’ve even published a post on this blog about it some while ago (Preparing your SailsJS application for production).
Like most NodeJS framworks, SailsJS takes only a couple of lines to install and get going.
What I particularly like is the fact that it uses something called generators. These allow you to do quick scaffolding of the web application.
To get started simply key in:
sails generate new <applicationName>
And a new SailsJS web application is generated. The application folder will contain everything required to run the web application. It includes the web server that will run the application.
To start the web application simply run:
sails lift
The web server embedded in the SailsJS web application is called Express JS. This is a very commonly used web server and we will see it used in the other NodeJS frameworks.
Also using the SailsJS generators you can setup REST API endpoints for your application.
Want to generate an API end point? It’s easy:
sails generate api test
This will generate a Test model object, a TestController module for handling all the REST API methods for retrieving, adding, updating and removing a Test object instance.
SailsJS can work with any database: relational or NoSQL. The data layer is database agnostic. This means that you work with the data in the same way no matter the database used.
This is possible by the use of Waterline, SailsJS’s ORM.
For the front-end things are also de-coupled. This is very good as it allows you to use any preferred front-end framework: Angular, React, etc.
Out of the box SailsJS offers WebSockets support for its REST API endpoints. This means that you can implement full-duplex communication for your web application.
Meteor
Meteor is another great NodeJS framework. It uses packages to encapsulate functional modules. It offers pre-build packages via it’s eco-system called AtmosphereJS.
Once installed, Meteor allows you to start writing web application right away:
meteor create <applicationName>
That will create the application folder which clearly separates the client and the server part.
To start the application you only need to key in meteor
from the application folder.
By default Meteor uses Blaze for its front-end. However it’s very easy to switch it to other front-end frameworks like Angular or React.
Meteor makes it very easy to store your application data in MongoDB out-of-the-box. It comes bundled with the framework and there’s a dedicated Meteor package for working with MongoDB.
Distributed Data Protocol (DDP) is querying a server-side database, sending the results down to the client, and then pushing changes to the client whenever anything changes in the database. Basically, when something changes in the database you immediately see the change in the UI without having to refresh the page or do AJAX polling. This is a big plus for the Meteor framework.
Another huge benefit of using Meteor is that you can easily re-use the code written for your web application and transform it into a mobile application for Android or iOS. Meteor makes this possible using of Cordova. This creates a mobile application with an embedded WebView that will run the client application.
As mentioned before Meteor works with packages. Pre-made packages are freely available via AtmosphereJS. There are hundreds of packages for all sort of application requirements (security, UI, etc.).
NestJS
I’ve only recently taken contact with NestJS. To me this NodeJS framework seems the most mature. Its philosophy revolves around design patterns.
TypeScript is a JavaScript meta-language. This means that you write TypeScript code and this will be transpiled into JavaScript code. The advantage is that TypeScript is much more strict and more evolved as a programming language. It has all sort of features from strong-types to decorators (something like Java’s annotations).
NestJS Uses Dependency Injection. Similar to Java’s Spring or Angular’s dependency injection, NestJS also uses dependency injection. This makes the application components more de-coupled which translates to a better application architecture.
NestJS makes use of an ORM called TypeORM which allows making the application database agnostic. So, you can painlessly switch between database back-ends.
Finally NestJS also runs the ExpressJS web server and it uses WebSockets for full-duplex communication. This makes it easy to have real-time data binding.
KrakenJS
The last NodeJS framework I chose for this list is KrakenJS. This is the framework I have worked with the less.
First of all, I have to tell you that this is the framework used and developed by PayPal. They developed it for replacing their old Java based web application.
Once installed via the NodeJS package manager (npm) you can easily get started using the yo
tool:
yo kraken
To start the application simply run this from the application folder:
npm start
KrakenJS also makes use of ExpressJS. It provides a very useful package called Lusca for OWASP security rules as an ExpressJS middleware.
Kraken uses LinkedIn’s Dust as the templating language of choice. And it also offers a few other interesting out-of-the-box functionalities like: localization, authentication/security, etc.
Thanks, Looking for TTF Files.
What do you mean? Life font files?