We have noticed that frameworks are your favourite topic! That is why this week we propose to talk about Nest.js: a Node.js framework. We will look at its technical characteristics and its advantages.
What features does this framework offer?
What above all makes Nest’s main strength is that it is based on JavaScript but built with TypeScript. It also brings in all the elements of the ES2015, ES2016 and ES2017 language versions. The framework combines elements of object-oriented programming (OOP), functional programming (FP) and functional reactive programming (FRP).
Nest.js uses many features from its competitor Express; however, its designers have set it apart by making it compatible with a large number of Node.js libraries such as Fastify.
Installing Nest.js
As with most frameworks and other tools, a few commands in your terminal are enough:
Creating and installing the project via npm:$ npm i -g @nestjs/cli $ nest new project-name
Creating and installing the project via GitHub:$ git clone <https://github.com/nestjs/typescript-starter.git> project $ cd project $ npm install $ npm run start
Technical characteristics
Here is a factual list of the technical elements of the Nest.js framework.
Authentication: for this part, the designers of Nest.js chose the Passport library (the most popular in Node.js). It is easy to integrate and, above all, very comprehensive.
Database: database management is handled by the ORM (object-relational mapper) TypeORM. It is developed in TypeScript, which means it works very well with the framework.
File uploads: to handle uploads, Nest.js uses a middleware: Multer. Its advantage is that it is fully configurable and therefore able to meet all your requirements.
Nest.js will allow you to use a wide selection of APIs through a module well known to developers:
The @nestjs/graphql module: a simple way of juggling GraphQL and Node.js. Once the framework is installed, you simply add all the packages using the command below:$ npm i --save @nestjs/graphql apollo-server-express graphql-tools graphql
For gateways, Nest.js uses the WebSocket module and more specifically the Socket.io library. It enables real-time, two-way communication between clients and servers.
Nest.js also has other technical features; to find out more, do read the documentation on the official website.