
There are four sections of this course: Introduction, skeleton of an application, persistence and tests. All of the sections will focus on basics of the NestJS. But it is not the end of the journey. I am going to constantly develop this course and mention all the interested topics connected with NestJS. There are many of them everywhere around. If you are interested in something, please write to me and I will take a look at your proposition.
In this section we will do a hello world application and explain the main concepts behind the NestJS framework. I would love to strongly focus on dependency injection and dependency injection container, because it is the foundation of the framework.
Before we start to discover nest.js power, we need to do some preparations. We need to have of course a PC with an operating system. I will work on Mac, but it’s really easy to work on another operating system also.
Additionally, you will need:
the package manager (like Brew for Mac),
Git,
NVM,
Node.js,
comfortable code editor (I recommend free Visual Studio Code),
Nest CLI.
In this lesson, we are going to create a Hello World application in NestJS. It is easy. We will use Nest CLI to generate a new Nest.js project. In the end, we will run our application and see the sentence "Hello World!" in the browser.
We will look into the structure of the generated application and we will see what is happening under the hood. I decided to divide this lesson into two parts. In this part, I will explain the basic concepts of Nest.js like module, controller and service.
We will continue looking under the hood of NestJS. In this lecture we will focus on tests, scripts available in package.json and tslint.json file.
Following the definition on Wikipedia dependency injection is a technique whereby one object supply the dependencies to another object. The practical implementation is quite simple and we really do not need NestJS at all.
NestJs is using much more powerful tool. NestJS is strongly using dependency injection container. Dependency Injection container makes dependency injection technique more automatic.
Dependency Injection pattern is one of the ways to implement Dependency Inversion Principle, a SOLID rule.
I hope you enjoy NestJS. There were a lot of concepts and explanations here. The next sections are going to be more practical ones.
In this section we will focus on the business logic of the application. We will create our first module and a service inside. This module will also consist of a controller and both - unit and e2e tests.
In this lesson we will just change the metadata of our application. It’ll be no more hello world application. It is gonna be nice location storage.
In this lesson we will focus on setting up the template engine and generate simple page.
Changes in our application can change the behavior of our tests. Take care about it and not forget to run all the tests. We've broken the e2e test and will fix it.
Modules are really powerful tools in the developer's hands. Thanks to them, we can reduce the scope of a big application to nicely separated modules. Each module can be maintained by a different person or even a different team so there should be loosely coupled connections between modules.
In this lesson we will focus on creating a location module.
Every module has its own structure consisting of controllers, services and persistence layer. In this lesson, we will focus on a service.
We have created a nicely separated location module being the proud, first chunk of the application. Such module consist of all business logic connected with locations.
In the last section we did a really huge refactor and we have broken most of the tests. In this section we will make them great again.
I promised to come back with an explanation of the way to correctly handle the config of our application.
Installing PostgreSQL is just a prerequisite to our journey to the persistence layer.
In this lesson we are going to set up the connection between the application and Postgres database.
In this lesson we are going to create a new entity. It is going to be a preparation for a greater refactor.
I am gonna show you how to transform entities to DTO. This lecture might last long - I decided to divide this lecture into two parts.
In this lesson, I am gonna transform entities to DTO. It is the second part about transforming entities to DTOs.
We have done quite a huge refactor and introduced a lot of additional concepts focused on persistent layer mostly. I would love to recapitulate all the knowledge in this lesson.
In the last section we did really nice job implementing the persistence layer. Thanks that we achieved nice separation between the particular layers of the application. That was really huge refactor and we’ve broken most of the tests. In this section we will make them great again.
We will need some mocking library. I have chosen Sinon which I find the best.
We are going to fix location.service.ts.
Generic factory is a test helper tool that will create the mocked entities.
We have created a generic factory. Let's use it to mock the entities.
MockHelper is just an abstraction created to avoid code duplications in the unit tests.
We are going to fix location.controller.spec.ts.
It is the easiest test to fix, because it is a blackbox test. Our app behaves almost like before. There are just some cosmetically changes in the templates.
We have fixed all the tests. We will create a new ones shortly.
NestJS (or simply Nest) is fresh, easy to start and challenging to master node.js framework drawing on the best SOLID patterns but written to create modern applications. There are dedicated modules such as GraphQL module, WebSockets module, MicroServices module.
Nest documentation describes mature patterns and tools broadening developers horizons, like CQRS, OpenAPI, Prisma etc.
If I could say something to myself at the beginning of my career, I would advise to learn the mechanisms of mature frameworks and read Uncle Bob’s books.
I love node.js and Nest is one of the best parts of it.
This course will guide you from the beginning to the most advanced use cases. I intend to constantly update it to be up to date with your needs and all the news. Let's create the best complete NestJS course together.