Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Nest.js: A Progressive Node.js Framework

You're reading from  Nest.js: A Progressive Node.js Framework

Product type Book
Published in Nov 2019
Publisher Packt
ISBN-13 9781800204737
Pages 317 pages
Edition 1st Edition
Languages
Authors (5):
Greg Magolan Greg Magolan
Profile icon Greg Magolan
Patrick Housley Patrick Housley
Profile icon Patrick Housley
Adrien de Peretti Adrien de Peretti
Profile icon Adrien de Peretti
Jay Bell Jay Bell
Profile icon Jay Bell
David Guijarro David Guijarro
Profile icon David Guijarro
View More author details

Table of Contents (16) Chapters

Preface
1. Introduction 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 €14.99/month. Cancel anytime}