📜 ⬆️ ⬇️

An overview of the new features of NestJS 6

We in TestMace actively use NestJS to develop our services. Today, your attention is the translation of an article devoted to the review of the features of the new major version of NestJS.



Today, I am pleased to present the official release of Nest 6 - a progressive Node.js framework for creating efficient enterprise server applications.


For our community, the last year has not passed without a trace: popularity has grown by almost 300%, which is 4 times more than any of the existing HTTP libraries. About Nest told at a large number of conferences around the world, was created many articles and videos. 2018 was incredible, and 2019 will be even better!


What's new?


New release is preparing a lot of cool features! Unfortunately, we will not have time to light them all, but we will certainly dwell on the hottest ones!


Injection scopes


In previous versions of Nest, each provider was shared by several requests. Using singletones reduces memory consumption and improves application performance.


However, in some cases, you may need additional control over the life cycle of each of the providers. For example, when implementing a separate cache for each query in a GraphQL application when creating multi-user systems. To solve such problems, the IoC container now has another level of detail that allows you to create new injection scopes —Transient Scope and Request Scope.



→ You can read more about them here.
')

Platforms


Nest is a full-scale and platform-independent framework. Thanks to this, developers can create logical blocks that can be reused in applications of various types. With Nest, you can easily create a web application, a console utility, a job queue, and anything else! We brought all the functionality related to the platform into separate packages like @nestjs/platform-express , and now you can write even less code. Just install everything you need for your application!

Developments


Previously, the operation of each microservice communication channel was built on the basis of the request / response paradigm. This interaction mechanism was perfect for exchanging messages between numerous external services. After seeing the confirmation, you could be sure that the service actually received the message.


However, for some systems it is not necessary to create bidirectional channels, since this leads to unnecessary overhead costs when you only need to publish the event (without asking for any answer). That is why we introduced event based messaging. Due to this paradigm, it is enough just to notify various services with a message if, for example, a certain situation has occurred somewhere in the system.



It also turned out that this solution in the future will provide an opportunity to integrate more complex messaging platforms. Follow the news!


GraphQL ♡ TypeScript


One of the most common problems with GraphQL is type redundancy. Solving this problem in the previous version of Nest, we added a compiler that turns definitions written in SDL into TypeScript interfaces (or classes).

Nest version 6.0.0 boasts a type-graphql package that allows you to generate GraphQL files using only TypeScript decorators! Now there are two ways to choose from, and you can decide for yourself what is more suitable for specific needs. Both approaches are provided in the @nestjs/graphql .

→ Read more about it here.

CLI


The underlying Nest Angular DevKit package has been updated, which means that the command line interface now shows prompts . Moreover, we added support for nest g lib , which will help simplify development when using a single repository.


Documentation


Nest's official documentation has been reworked, and now it is completely written on Markdown . In our opinion, it will be much easier to work with documentation, and over time we will be able to make it even better.


Partners and community


Good news: Angular Console (UI for Angular CLI) now supports Nest!




Nest is becoming the main solution for building structured, scalable Node applications in the Angular repository.


In addition, we recently launched the official Discord channel. Subscribe to the channel and join the discussion of Nest and other interesting topics!


Transition from Nest 5


Follow the instructions to migrate existing projects. You should get rid of any warnings about the undesirability of using any part of the program that may appear in the console.


Support


Nest is an open source MIT licensed project. Its current development was made possible thanks to the support of the community, our main sponsor - Valor Software and other companies. Recently, two more sponsors joined the list - Blueanchor and NovoLogic . Thanks you!


We had to go a long way, working late into the weekend, not seeing sleep for days for our framework to be born. I believe that good will save the world! ️


If you would like to contribute to our project, follow the link .


Future plans


There are still some points in the ecosystem that I would like to improve.




I already have several ideas planned for implementation in the coming months.


Acknowledgments


We thank the sponsors, the community and all those involved! We create our product for you , and we are only at the beginning of a long journey.

Source: https://habr.com/ru/post/447554/


All Articles