SlideShare a Scribd company logo
Solid NodeJS
with TypeScript, Jest & Nest
“We build our computer systems
the way we build our cities:
over time, without a plan, on top of ruins.”
Ellen Ullman
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 3
Flexibility
Its multi-paradigm nature, dynamic type
system and minimal core allow great flexibility.
Ecosystem
Great system with largest amount of
packages and best evolution.
Ubiquity
Presence both in client and server, along with
mobile environment and almost everywhere.
JavaScript
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 4
Modularity
Keep simple parts short,
connected with clean interfaces.
Composition
Make those independent packages
work together to build applications
Simplicity
JavaScript succinct syntax and flexibility,
along with Node inherent asynchrony
NodeJS
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 5
Lack of common architecture
Different approaches for directory and file structure,
and even module design.
Fragile execution
Input / Output non-standard type validation,
lack of testable parts because of coupling and derived
problems from lack of standards.
Problematic growth
Hard to scale and distribute work among
different developers and teams.
Medium to Large NodeJS Applications
What’s the STRUCTURE?
How do I get ROBUSTNESS?
What if I need SCALABILITY?
Application Issues
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 6
Jest
Testing complete solution,
with zero config, fast execution,
and built-in coverage
.
Nest
Framework based on
combination of OOP/FP/FRP,
DI and building blocks.
TypeScript
JavaScript that scales
through latest features
and solid type static analysis.
Weapons
Solutions for Robustness, Scalability and Structure
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 7
Why TypeScript?
๏ Types are optional (ideal for
validation)
๏ Type inference for static analysis
and tooling
๏ Interfaces for solid components
๏ Advanced ESNext features in
Development
๏ Compiles to clean, efficient,
compatible JavaScript
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 8
Why Jest?
๏ Complete Testing Solution
๏ Minimum configuration
๏ Fast parallelization of tests across
workers
๏ Selective execution when
watching
๏ Built-in code coverage report with
Istanbul
๏ Snapshot Testing included
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 9
Application Architecture
Nest provides building blocks around a execution
context to give a common architecture, that includes
controllers, modules, pipes, guards, etc.
Middleware structure
Built on top of Express, it leverages the
middleware capabilities of this framework..
Dependency Injection
All elements in Nest are defined around
DI principles, so services, modules, controllers,
all can be injected and thus easily testable.
Platform-agnostic
Reusable pieces that can be used in
different contexts, like GraphQL, Microservices
or Websockets..
Nest
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 10
• Starter with TypeScript
• V5 is coming (beta) with

dedicated CLI
• Basic structure with

conventions
• Main entry point
First steps
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 11
๏ Each Part of the Application
๏ Can be only one: Root Module
๏ Domain Bounded Contexts
๏ Module Decorator describes:
➡ Imports: Other modules
➡ Controllers: Created by the module
➡ Components/Providers: Instantiated and shared

across the module
๏ Modules are Singletons so they are shared.
Modules
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 12
Every Module can Import

and Export other Modules
Admin ModuleUsers Module
Application Module
Stats ModuleBilling ModuleChat Module Game Module
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 13
Example
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 14
Controllers
๏ Request Handlers and Response Generators
๏ Must be declared associated to a Module
๏ Metadata in decorator defines prefix like @Controller(‘users’)
๏ Two approaches to handle Response:
➡ Nest: Returns Array or Object automatically as JSON
➡ Express: Injected through @Res() decorator.

Allow express-like response manipulation.
๏ POST handler can use Data Transfer Object (DTO)
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 15
Example
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 16
Components / Providers
๏ Services, Factories, Helpers, etc
๏ They can be Injected into Controllers or

other Components / Providers through constructor
๏ Any complex task performed into Controllers
๏ Pattern of reusability and modularity
๏ Plain TypeScript Classes
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 17
Example
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 18
Middlewares
๏ Function called before the Route Handler
๏ Have access to Request, Response and Next handler
๏ Same capabilities as express middlewares:
➡ Execute code before continuing: And then call next()
➡ Make changes to Request & Response
➡ End Request-Response cycle
๏ Can be defined:
➡ For specific paths
➡ For specific Controllers
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 19
Example
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 20
Exceptions
๏ Global Exception Filter for Unhandled Errors: 500 Server Error
๏ Built-in HttpException that when thrown by handler

it transforms to proper JSON response
๏ A good practice is to create your own Exception Hierarchy with

exceptions inherited by the HttpException class
๏ Nest offers several built-in HTTP Exceptions like:

BadRequestException, UnauthorizedException, 

NotFoundException, ForbiddenException, etc
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 21
Example
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 22
Validation
๏ Validation is done through a specific Pipe
๏ Pipes are classes that implement the PipeTransform Interface
๏ A Pipe transforms the input data to desired output before Route Handler
๏ ValidationPipe is a built-in Pipe
๏ Data Transfer Object (DTO) is required to receive the @Body()
๏ Class-Validator library allow decorator-based validation on DTO definition
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 23
Example
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 24
Testing with Jest
๏ Every building block in Nest (Components, Controllers, etc) are simple decorated classes
๏ As every dependency is injected through constructor, they are easy to mock
๏ Recommendation is to keep your test files near the implementation
๏ Recommendation is always isolated tests
๏ Test class is a utility with createTestingModule() that takes module metadata and creates

a TestingModule instance.
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 25
Example
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 26
Example
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 27
Database Access
๏ Nest uses by default the standard TypeORM for Object Relational Model
๏ Mongoose use the built-in @nestjs/mongoose package
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 28
Example
NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 29
GraphQL
Module for GraphQL
server with Apollo
Websockets
Decorators to include
WS transport
Microservices
NestJS microservices are
TCP interconnected services
Platform-agnosticism allow building apps
with several transport layers and contexts.
Always bet on JavaScript.
Let’s make JS applications more solid.
Let’s do it on scale.
“It's never on how difficult
is to write bad code,
it's on how easy is
to write great code.”
@yonatam
Thank you
No real requests were damaged during this talk.

More Related Content

What's hot (20)

PPTX
Node js Introduction
sanskriti agarwal
 
PPTX
Basic Concept of Node.js & NPM
Bhargav Anadkat
 
PDF
Introduction to Redux
Ignacio Martín
 
PDF
Angular Observables & RxJS Introduction
Rahat Khanna a.k.a mAppMechanic
 
PDF
A Separation of Concerns: Clean Architecture on Android
Outware Mobile
 
PPTX
React + Redux Introduction
Nikolaus Graf
 
PPTX
Domain Driven Design 101
Richard Dingwall
 
PPTX
Getting started with Next.js - IM Tech Meetup - Oct 2022.pptx
Ilesh Mistry
 
PDF
TypeScript
Saray Chak
 
PDF
An Introduction to Redux
NexThoughts Technologies
 
PPTX
Node js introduction
Joseph de Castelnau
 
PPTX
Introduction Node.js
Erik van Appeldoorn
 
PPTX
Domain Driven Design
Ryan Riley
 
PDF
Angular & RXJS: examples and use cases
Fabio Biondi
 
PPT
Node.js Express Framework
TheCreativedev Blog
 
PPTX
Introduction to Node js
Akshay Mathur
 
PDF
Domain Driven Design
Harsh Jegadeesan
 
PPTX
React js
Oswald Campesato
 
PPTX
Intro to React
Justin Reock
 
Node js Introduction
sanskriti agarwal
 
Basic Concept of Node.js & NPM
Bhargav Anadkat
 
Introduction to Redux
Ignacio Martín
 
Angular Observables & RxJS Introduction
Rahat Khanna a.k.a mAppMechanic
 
A Separation of Concerns: Clean Architecture on Android
Outware Mobile
 
React + Redux Introduction
Nikolaus Graf
 
Domain Driven Design 101
Richard Dingwall
 
Getting started with Next.js - IM Tech Meetup - Oct 2022.pptx
Ilesh Mistry
 
TypeScript
Saray Chak
 
An Introduction to Redux
NexThoughts Technologies
 
Node js introduction
Joseph de Castelnau
 
Introduction Node.js
Erik van Appeldoorn
 
Domain Driven Design
Ryan Riley
 
Angular & RXJS: examples and use cases
Fabio Biondi
 
Node.js Express Framework
TheCreativedev Blog
 
Introduction to Node js
Akshay Mathur
 
Domain Driven Design
Harsh Jegadeesan
 
Intro to React
Justin Reock
 

Similar to Solid NodeJS with TypeScript, Jest & NestJS (20)

PDF
How to make a high-quality Node.js app, Nikita Galkin
Sigma Software
 
PDF
Node.js for enterprise - JS Conference
Timur Shemsedinov
 
PPTX
DDD, CQRS and testing with ASP.Net MVC
Andy Butland
 
PDF
Elasticsearch Operations on K8s - Key Specificities
Tyler Nguyen
 
PDF
ASP.NET MVC Workshop for Women in Technology
Małgorzata Borzęcka
 
PPTX
Test Automation for NoSQL Databases
Tobias Trelle
 
PDF
IBM Think Session 8598 Domino and JavaScript Development MasterClass
Paul Withers
 
PDF
Treinamento frontend
Adrian Caetano
 
PDF
Node js (runtime environment + js library) platform
Sreenivas Kappala
 
PPTX
Node.js on Azure
Sasha Goldshtein
 
PPT
Linq 1224887336792847 9
google
 
PPTX
Just entity framework
Marcin Dembowski
 
PPTX
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
Chalermpon Areepong
 
PDF
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
mfrancis
 
PPT
Linq To The Enterprise
Daniel Egan
 
PPTX
MongoDB.pptx
Sigit52
 
PDF
Test Driven Development
Maris Prabhakaran M
 
ODP
Frankenstein's IDE: NetBeans and OSGi
Toni Epple
 
PDF
CDI Telco Framework & Arquillian presentation at Mobicents Summit, Sochi 2011
telestax
 
PPTX
Kalp Corporate Node JS Perfect Guide
Kalp Corporate
 
How to make a high-quality Node.js app, Nikita Galkin
Sigma Software
 
Node.js for enterprise - JS Conference
Timur Shemsedinov
 
DDD, CQRS and testing with ASP.Net MVC
Andy Butland
 
Elasticsearch Operations on K8s - Key Specificities
Tyler Nguyen
 
ASP.NET MVC Workshop for Women in Technology
Małgorzata Borzęcka
 
Test Automation for NoSQL Databases
Tobias Trelle
 
IBM Think Session 8598 Domino and JavaScript Development MasterClass
Paul Withers
 
Treinamento frontend
Adrian Caetano
 
Node js (runtime environment + js library) platform
Sreenivas Kappala
 
Node.js on Azure
Sasha Goldshtein
 
Linq 1224887336792847 9
google
 
Just entity framework
Marcin Dembowski
 
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
Chalermpon Areepong
 
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
mfrancis
 
Linq To The Enterprise
Daniel Egan
 
MongoDB.pptx
Sigit52
 
Test Driven Development
Maris Prabhakaran M
 
Frankenstein's IDE: NetBeans and OSGi
Toni Epple
 
CDI Telco Framework & Arquillian presentation at Mobicents Summit, Sochi 2011
telestax
 
Kalp Corporate Node JS Perfect Guide
Kalp Corporate
 
Ad

More from Rafael Casuso Romate (12)

PDF
Rise and Fall of the Frontend Developer
Rafael Casuso Romate
 
PDF
Nuxt Avanzado (de Scaffolding a MVP)
Rafael Casuso Romate
 
PDF
The Core of Agile
Rafael Casuso Romate
 
PDF
The Voice Interface Revolution
Rafael Casuso Romate
 
PDF
Introduction to Weex: Mobile Apps with VueJS
Rafael Casuso Romate
 
PDF
Component-Oriented Progressive Web Applications with VueJS
Rafael Casuso Romate
 
PDF
Intro to VueJS Workshop
Rafael Casuso Romate
 
PDF
Google Assistant Revolution
Rafael Casuso Romate
 
PDF
VueJS in Action
Rafael Casuso Romate
 
PDF
JavaScript Editions ES7, ES8 and ES9 vs V8
Rafael Casuso Romate
 
PDF
VueJS: The Simple Revolution
Rafael Casuso Romate
 
PDF
Microservices Architecture For Conversational Intelligence Platform
Rafael Casuso Romate
 
Rise and Fall of the Frontend Developer
Rafael Casuso Romate
 
Nuxt Avanzado (de Scaffolding a MVP)
Rafael Casuso Romate
 
The Core of Agile
Rafael Casuso Romate
 
The Voice Interface Revolution
Rafael Casuso Romate
 
Introduction to Weex: Mobile Apps with VueJS
Rafael Casuso Romate
 
Component-Oriented Progressive Web Applications with VueJS
Rafael Casuso Romate
 
Intro to VueJS Workshop
Rafael Casuso Romate
 
Google Assistant Revolution
Rafael Casuso Romate
 
VueJS in Action
Rafael Casuso Romate
 
JavaScript Editions ES7, ES8 and ES9 vs V8
Rafael Casuso Romate
 
VueJS: The Simple Revolution
Rafael Casuso Romate
 
Microservices Architecture For Conversational Intelligence Platform
Rafael Casuso Romate
 
Ad

Recently uploaded (20)

PDF
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PDF
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
PPTX
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PPTX
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
PPTX
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
PPTX
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PDF
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PPTX
Engineering the Java Web Application (MVC)
abhishekoza1981
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
Platform for Enterprise Solution - Java EE5
abhishekoza1981
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Revolutionizing Code Modernization with AI
KrzysztofKkol1
 
The Role of a PHP Development Company in Modern Web Development
SEO Company for School in Delhi NCR
 
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Efficient, Automated Claims Processing Software for Insurers
Insurance Tech Services
 
Tally software_Introduction_Presentation
AditiBansal54083
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
Engineering the Java Web Application (MVC)
abhishekoza1981
 
Human Resources Information System (HRIS)
Amity University, Patna
 

Solid NodeJS with TypeScript, Jest & NestJS

  • 2. “We build our computer systems the way we build our cities: over time, without a plan, on top of ruins.” Ellen Ullman
  • 3. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 3 Flexibility Its multi-paradigm nature, dynamic type system and minimal core allow great flexibility. Ecosystem Great system with largest amount of packages and best evolution. Ubiquity Presence both in client and server, along with mobile environment and almost everywhere. JavaScript
  • 4. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 4 Modularity Keep simple parts short, connected with clean interfaces. Composition Make those independent packages work together to build applications Simplicity JavaScript succinct syntax and flexibility, along with Node inherent asynchrony NodeJS
  • 5. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 5 Lack of common architecture Different approaches for directory and file structure, and even module design. Fragile execution Input / Output non-standard type validation, lack of testable parts because of coupling and derived problems from lack of standards. Problematic growth Hard to scale and distribute work among different developers and teams. Medium to Large NodeJS Applications What’s the STRUCTURE? How do I get ROBUSTNESS? What if I need SCALABILITY? Application Issues
  • 6. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 6 Jest Testing complete solution, with zero config, fast execution, and built-in coverage . Nest Framework based on combination of OOP/FP/FRP, DI and building blocks. TypeScript JavaScript that scales through latest features and solid type static analysis. Weapons Solutions for Robustness, Scalability and Structure
  • 7. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 7 Why TypeScript? ๏ Types are optional (ideal for validation) ๏ Type inference for static analysis and tooling ๏ Interfaces for solid components ๏ Advanced ESNext features in Development ๏ Compiles to clean, efficient, compatible JavaScript
  • 8. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 8 Why Jest? ๏ Complete Testing Solution ๏ Minimum configuration ๏ Fast parallelization of tests across workers ๏ Selective execution when watching ๏ Built-in code coverage report with Istanbul ๏ Snapshot Testing included
  • 9. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 9 Application Architecture Nest provides building blocks around a execution context to give a common architecture, that includes controllers, modules, pipes, guards, etc. Middleware structure Built on top of Express, it leverages the middleware capabilities of this framework.. Dependency Injection All elements in Nest are defined around DI principles, so services, modules, controllers, all can be injected and thus easily testable. Platform-agnostic Reusable pieces that can be used in different contexts, like GraphQL, Microservices or Websockets.. Nest
  • 10. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 10 • Starter with TypeScript • V5 is coming (beta) with
 dedicated CLI • Basic structure with
 conventions • Main entry point First steps
  • 11. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 11 ๏ Each Part of the Application ๏ Can be only one: Root Module ๏ Domain Bounded Contexts ๏ Module Decorator describes: ➡ Imports: Other modules ➡ Controllers: Created by the module ➡ Components/Providers: Instantiated and shared
 across the module ๏ Modules are Singletons so they are shared. Modules
  • 12. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 12 Every Module can Import
 and Export other Modules Admin ModuleUsers Module Application Module Stats ModuleBilling ModuleChat Module Game Module
  • 13. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 13 Example
  • 14. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 14 Controllers ๏ Request Handlers and Response Generators ๏ Must be declared associated to a Module ๏ Metadata in decorator defines prefix like @Controller(‘users’) ๏ Two approaches to handle Response: ➡ Nest: Returns Array or Object automatically as JSON ➡ Express: Injected through @Res() decorator.
 Allow express-like response manipulation. ๏ POST handler can use Data Transfer Object (DTO)
  • 15. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 15 Example
  • 16. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 16 Components / Providers ๏ Services, Factories, Helpers, etc ๏ They can be Injected into Controllers or
 other Components / Providers through constructor ๏ Any complex task performed into Controllers ๏ Pattern of reusability and modularity ๏ Plain TypeScript Classes
  • 17. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 17 Example
  • 18. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 18 Middlewares ๏ Function called before the Route Handler ๏ Have access to Request, Response and Next handler ๏ Same capabilities as express middlewares: ➡ Execute code before continuing: And then call next() ➡ Make changes to Request & Response ➡ End Request-Response cycle ๏ Can be defined: ➡ For specific paths ➡ For specific Controllers
  • 19. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 19 Example
  • 20. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 20 Exceptions ๏ Global Exception Filter for Unhandled Errors: 500 Server Error ๏ Built-in HttpException that when thrown by handler
 it transforms to proper JSON response ๏ A good practice is to create your own Exception Hierarchy with
 exceptions inherited by the HttpException class ๏ Nest offers several built-in HTTP Exceptions like:
 BadRequestException, UnauthorizedException, 
 NotFoundException, ForbiddenException, etc
  • 21. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 21 Example
  • 22. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 22 Validation ๏ Validation is done through a specific Pipe ๏ Pipes are classes that implement the PipeTransform Interface ๏ A Pipe transforms the input data to desired output before Route Handler ๏ ValidationPipe is a built-in Pipe ๏ Data Transfer Object (DTO) is required to receive the @Body() ๏ Class-Validator library allow decorator-based validation on DTO definition
  • 23. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 23 Example
  • 24. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 24 Testing with Jest ๏ Every building block in Nest (Components, Controllers, etc) are simple decorated classes ๏ As every dependency is injected through constructor, they are easy to mock ๏ Recommendation is to keep your test files near the implementation ๏ Recommendation is always isolated tests ๏ Test class is a utility with createTestingModule() that takes module metadata and creates
 a TestingModule instance.
  • 25. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 25 Example
  • 26. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 26 Example
  • 27. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 27 Database Access ๏ Nest uses by default the standard TypeORM for Object Relational Model ๏ Mongoose use the built-in @nestjs/mongoose package
  • 28. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 28 Example
  • 29. NODEJS SÓLIDO CON TYPESCRIPT, JEST Y NESTJS. 29 GraphQL Module for GraphQL server with Apollo Websockets Decorators to include WS transport Microservices NestJS microservices are TCP interconnected services Platform-agnosticism allow building apps with several transport layers and contexts.
  • 30. Always bet on JavaScript. Let’s make JS applications more solid. Let’s do it on scale. “It's never on how difficult is to write bad code, it's on how easy is to write great code.” @yonatam
  • 31. Thank you No real requests were damaged during this talk.