Logo preloader Xtension

Nest.js, or Angular and Spring on the backend

Nest.js is a framework for writing web applications for node.js. The structure of the code is modelled on Angular, so we have here mainly modules and services and dependency injection. And most importantly, the application is created in TypeScript. If you have positive experience with Spring in Java and you like the dependency injection mechanism, which is proposed by Angular, this topic will certainly be of interest to you.
javascript
coding
nest.js

Nest.js is to JavaScript what Spring is to Java, that is, it provides mechanisms for creating controllers. It then uses decorators - to denote methods that support specific methods, e.g. @Get, @Post, etc., and to denote the controllers themselves by means of decorators. It then uses decorators - to mark the methods that support specific methods, e.g. @Get, @Post etc., and to mark the controllers themselves with the @Controller() decorator (the parameter of this decorator is the path to the resource). For the service classes that will be injected, we in turn add the @Injectable decorator.

We also have a tool for creating an initial project and its individual components (module, controller, service and many others).

The framework benefits from other libraries and frameworks. Under the hood we will find express js as a http server by default. Optionally, you can use another engine - the architecture theoretically allows you to plug in any http server.

A popular passport js framework is used for authentication. When using the standard user/password method for this purpose, its use comes down to writing a service
and implementing a single method.

Also included is a database client along with mapping relationships to objects - the typeorm library is used here. If someone uses MongoDb, they will also find Mongoose on board.

The framework integrates several other libraries and provides mechanisms to implement many different scenarios (such as microservices or graphql). It is very well documented. The official documentation page presents every aspect of this library in detail, along with examples. The entry threshold is very low, especially if you already have experience with the technologies mentioned at the very beginning.

I think that this is a very successful project, which takes a comprehensive approach to backend development using many proven solutions. Its popularity and maturity is confirmed by the fact that on github at the time of writing these words the project has 23 thousand stars. If you are considering developing a web application on the node.js platform, this is a very good starting point.

Publication date: 24 June 2020
Author: Michał Gierwatowski
Read the next articles
Mobile
Certum
Security
signaturiX. Sign on your smartphone!
Mobile
Certum
Security
How to combine PRINCE2 and Scrum?
Mobile
Certum
Security
Biometric signature - the future of business
Let's create a unique project together
Write to us

Xtension Sp z o.o.

ul. Opacka 12

80-338 Gdańsk

 

+48 58 351 39 66

biuro@xtension.pl

 

LinkedIn