Background
The last years have shown that writing big, scalable server-side applications using JavaScript is possible thanks to Node.js. The huge community gives us a lot of space to show off when it comes to choosing a framework and packages. It also gives us a lot of ease while constructing the project itself.
The only question is whether the organization and architecture maintenance through so many different approaches, frameworks, and thousands of packages is good for long term support and if it allows further development of the application. While looking for answers, we came across a need for some structure in the architecture. In fact, it’s a must for the cooperation to be easy and pleasant for developers using it. Solving problems that appear during development, we found the solution in one place.
A good answer for all the questions that bother us is Nest.js.
Introducing Nest.js
The creator describes it as a reliable, effective, easily scaled, and progressive framework, for usage in big and small projects.
But why?
If you had something to do with the Angular frontend framework before, then you would have quickly noticed the similarities. It’s definitely not a coincidence. The creator of Nest.js was inspired by the mechanisms that the Angular developers had installed while designing the environment to build the frontend application. He decided to move this idea into the world of server-side which ensured the wide-scale usage of known architecture that employs elements such as modules, dependency injection, providers, custom decorators, and many more.
It sounds like reinventing the wheel…
You may be thinking that we already have many propitious and mature products like Node.js which are ready to be used in the environment of manufacture and have been tested by thousands. At the same time it seems like the Nest.js will require additional implementation of mechanisms for: http server, routing, exception filters, or database layer. Well, not quite.
So how does it work?
Fine-tuning of certain layers of the application which could be potentially used later on requires many months or even years of work and a large community to adjust all the elements getting through the accumulating problems. That’s why Nest.js doesn’t employ its own implementations but uses already existing possibilities creating its layers of abstraction and solving the biggest problems you may come across in the application – architecture. It ensures keeping order and combining many tested technologies into a one huge framework.
Using the default transpiler Babel.js that allows strong typing through the modern language TypeScript helps avoiding obstacles writing in pure JavaScript.
For example, Nest.js applies many known technologies used in other applications:
- Babel
- Webpack
- Jest
- Express
- TypeOrm
- Rxjs
- Apollo Server
- Mongoose
- Dotenv
- Class-validator
- Class-transformer
- Node-cron
- Expressjs/compression
- Helmet
- Bull
- Multer
- Axios
- Socket.io or ws
- Redis
- MQTT
- RabbitMQ
… and many more.
When is Nest.js a good solution for Node.js server-side applications?
Always, seriously… But why?
It doesn’t matter whether you are facing the challenge of writing a complex application divided into hundreds of microservices with advanced queuing mechanisms, or just a simple REST backend with numerous options of modification and the usage of already solved problems. In addition, it’s always a good idea to impose a ready-made architecture. Thus many developers understand our way of thinking.
Additionally, there are many online tutorials prepared by the author himself, and a broad, constantly rising community successfully supporting the whole product.
Struggles and problems
Our experience shows that most of occuring problems result from working in a given framework and due to lack of knowledge or its incorrect use. The bigger problems are: ways of migration in the databases or communication between applications. It happens when we don’t scare away all the bugs caused by one of the applied technologies rather than a problem with the framework.
Conclusions
So, do we feel comfortable using this technology? The answer is – yes.
Nest.js gives us a great sense of using something that is supported on many levels, ensures a reliable assistance to the community, and gives considerable development opportunities for already existing applications in this very approach.
If you are wondering whether it’s worth the shot and you have some experience with the Angular technology, or you just have a basic knowledge on how server-side applications work and how basic project patterns look – then it’s a good idea.
If you want to evolve along with our team, don’t hesitate to contact us and talk it through.
Let the meow be with you!