Slide 1

Slide 1 text

EXPLORING NEST.JS Alfredo Bonilla @brolag

Slide 2

Slide 2 text

WHAT IS NEST.JS? • Nest.js is a Node.js framework written in TypeScript for building back end applications. It combines elements of Object Oriented Programming, Functional Programming and Functional Reactive Programming. • It’s very reminicent to Angular.

Slide 3

Slide 3 text

WHAT DOES IT TRY TO SOLVE? • It helps providing an opinionated architecture for complex node.js application by making easy to: • Decouple modules. • Organize code per feature. • Decouple Transfer Layer (HTTP, Web Sockets). • TypeScript.

Slide 4

Slide 4 text

MAIN FEATURES

Slide 5

Slide 5 text

CONTROLLERS • Controllers are responsible for handling incoming requests and returning responses to the client.

Slide 6

Slide 6 text

CONTROLLERS

Slide 7

Slide 7 text

CONTROLLERS

Slide 8

Slide 8 text

DEPENDENCY INJECTION • Dependency Injection is the technique of supplying a dependent object, such as a module or component, with a dependency like a service, thereby injecting it into the component’s constructor.

Slide 9

Slide 9 text

DEPENDENCY INJECTION

Slide 10

Slide 10 text

DEPENDENCY INJECTION

Slide 11

Slide 11 text

MODULES • A module is a class annotated with a @Module() decorator. • The @Module() decorator provides metadata that Nest.JS makes use of to organize the application structure.

Slide 12

Slide 12 text

MODULES

Slide 13

Slide 13 text

MODULES

Slide 14

Slide 14 text

MODULES

Slide 15

Slide 15 text

MODULES

Slide 16

Slide 16 text

MIDDLEWARE • Middleware is a function which is called before the route handler. • Middleware functions have access to the request and response objects, and the next() middleware function in the application’s request-response cycle.

Slide 17

Slide 17 text

MIDDLEWARE

Slide 18

Slide 18 text

ORM • Nest.js can be integrated with: • TypeORM • Mongoose • Sequelize

Slide 19

Slide 19 text

WEBSOCKETS • Nest.js make use of socket.io package under the hood, but also, provide compatibility with a wide range of other libraries, including native web sockets implementation.

Slide 20

Slide 20 text

MICROSERVICES • Nest microservice is a type of application that uses a different transport layer than HTTP. • In general, Nest supports several built-in transporters. • This makes it easy to switch between transporters without changing the line of code.

Slide 21

Slide 21 text

MICROSERVICES

Slide 22

Slide 22 text

OPEN API • The OpenAPI (Swagger) specification is a powerful definition format to describe RESTful APIs. Nest provides a dedicated module to work with it.

Slide 23

Slide 23 text

OPEN API

Slide 24

Slide 24 text

CQRS • Command Query Responsibility Segregation (CQRS) is the idea that each method should either be one that performs an action (command) or requests data (query), but not both.

Slide 25

Slide 25 text

TESTING • The main Nest application starter is integrated with Jest framework to reduce an amount of overhead when it comes to start writing your tests, but still, you can get rid of it and use any other tool easily.

Slide 26

Slide 26 text

SERVER SIDE RENDERING • Nest.js supports Angular Server Side Rendering by using Angular Universal features.

Slide 27

Slide 27 text

TOOLING Nest CLI • Nest CLI is a command-line interface tool that helps to initialize and develop your applications. • The Nest CLI is based on the Angular Devkit package

Slide 28

Slide 28 text

RESOURCES • https://docs.nestjs.com/ • https://twitter.com/kammysliwiec • https://github.com/juliandavidmr/aweso me-nestjs • https://youtu.be/f0qzBkAQ3mk • https://youtu.be/ixz0IefmecI • Book

Slide 29

Slide 29 text

THANKS