Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Nest.js: A Progressive Node.js Framework

You're reading from   Nest.js: A Progressive Node.js Framework Hit the ground running with Nest.js

Arrow left icon
Product type Paperback
Published in Nov 2019
Publisher Packt
ISBN-13 9781800204737
Length 317 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (6):
Arrow left icon
Greg Magolan Greg Magolan
Author Profile Icon Greg Magolan
Greg Magolan
Patrick Housley Patrick Housley
Author Profile Icon Patrick Housley
Patrick Housley
Backstop Media LLC Backstop Media LLC
Author Profile Icon Backstop Media LLC
Backstop Media LLC
Adrien de Peretti Adrien de Peretti
Author Profile Icon Adrien de Peretti
Adrien de Peretti
Jay Bell Jay Bell
Author Profile Icon Jay Bell
Jay Bell
David Guijarro David Guijarro
Author Profile Icon David Guijarro
David Guijarro
+2 more Show less
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface
1. Introduction FREE CHAPTER 2. Overview 3. Nest.js authentication 4. Dependency Injection system of Nest.js 5. TypeORM 6. Sequelize 7. Mongoose 8. Web sockets 9. Microservices 10. Routing and request handling in Nest.js 11. OpenAPI (Swagger) Specification 12. Command Query Responsibility Separation (CQRS) 13. Architecture 14. Testing 15. Server-side Rendering with Angular Universal

Nest specific tools

Nest provides a set of Nest.js specific tools that can be used throughout the application to help with writing reusable code and following SOLID principles. These decorators will be used in each of the subsequent chapters, as they define a specific functionality:

  1. @Module: The definition for this reusable package of code within the project, it accepts the following parameters to define its behavior. ⋅⋅ Imports: These are the modules that contain the components used within this module. ⋅⋅ Exports: These are the components that will be used in other modules, that import this module. ⋅⋅ Components: These are the components that will be available to be shared across at least this module through the Nest Injector. ⋅⋅ Controllers: The controllers created within this module, these will define the API endpoints based on the routes defined.
  2. @Injectable: Almost everything in Nest is a provider that can be injected through constructors. Providers are annotated with @Injectable(). .. Middleware: A function that is run before a request is passed to the route handler. In this chapter, we will talk about the difference between Middleware, Async Middlewares and Functional Middleware. .. Interceptor: Similar to Middleware, they bind extra logic before and after the execution of a method, and they can both transform or completely override a function. Interceptors are inspired by Aspect-Oriented Programming (AOP). .. Pipe: Similar to part of an Interceptors functionality, Pipe transforms input data to the desired output. .. Guard: A smarter and more niche Middleware, Guards have the singular purpose of determining if a request should be handled by the router handler or not. ..* Catch: Tell an ExceptionFilter what exception to look for and then bind data to it.
  3. @Catch: Binds metadata to the exception filter and tells Nest that a filter is looking only for the exceptions listed in the @Catch.

Note: In Nest Version 4 not everything under @Injectable() listed above uses the @Injectable() decorator. Components, Middlewares, Interceptors, Pipes, and Guards each have their own decorator. In Nest Version 5 these have all been combined to @Injectable() to reduced the differences between Nest and Angular.

You have been reading a chapter from
Nest.js: A Progressive Node.js Framework
Published in: Nov 2019
Publisher: Packt
ISBN-13: 9781800204737
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime