Overview of NestJS 6 New Features

Original author: Kamil Mysliwiec
  • Transfer
We at TestMace are actively using NestJS to develop our services. Today, your attention is a translation of an article devoted to a 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. They talked about Nest at a large number of conferences around the world, and many articles and videos were created. 2018 was incredible, and 2019 will be even better!


What's new?


The new release is preparing many cool features! Unfortunately, we will not have time to cover them all, but we will definitely focus on the hottest of them!


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, additional control over the life cycle of each provider may be necessary. 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, allowing you to create new injection scopes — the Transient Scope and Request Scope.



→ You can read more about them here.

Platforms


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

Events


Previously, the operation of each microservice communication channel was built on the basis of a request / response paradigm. This kind of interaction mechanism was perfect for messaging between multiple external services. Seeing the confirmation, you could be sure that the service really received the message.


However, for some systems it is not necessary to create bidirectional channels, since this leads to unnecessary overhead when you just need to publish an event (without asking for any answer). That is why we introduced event-based messaging . Thanks to this paradigm, it is enough just to notify various services with a message if, for example, a certain situation has arisen 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 a 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 package type-graphqlthat allows you to generate GraphQL files with TypeScript decorators alone! Now there are two ways to choose from, and you can decide for yourself which is more suitable for specific needs. Both approaches are provided in a package @nestjs/graphql.

→ More about this here

CLI


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


Documentation


The official Nest documentation has been redesigned and is now fully written in Markdown . In our opinion, it will be much easier to work with documentation, and in 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 becomes the premier solution for creating 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!


Migrating 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 have joined this list - Blueanchor and NovoLogic . Thanks you!


We had to go a long way, working late into the weekend and not having sleep for days, so that our framework was 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.

  • We would like to rewrite the Swagger module to use TypeScript AST. This will add many new useful features. Read more about it here .
  • More complex, real-world authentication examples for various providers.
  • Deploy serverless applications and more DevOps!
  • The official video course!
  • Educational articles.

Acknowledgments


Thanks to the sponsors, the community and everyone involved! We create our product for you , and we are only at the beginning of a long journey.

Also popular now: