SlideShare a Scribd company logo
Nest.js Introduction
Takuya Tejima
Nest.js is a Node.js Framework for building application
- Architecture oriented approach
- Highly testable, scalable, loosely coupled, and easily
maintainable
- Smoothly build progressive app
- The architecture is heavily inspired by Angular
- DI/Devtools/websocket etc
- For the nodejs server layer can be switched to any of
other nodejs server library such as Express and Fastify
https://docs.nestjs.com/
What is Nest.js
Modules
- https://docs.nestjs.com/modules
Modules
- Modules with DI system (Angular inspired)
- Split to Reusable unit
- Imports
- list of imported modules that export the providers
which are required in this module
- Controllers
- the set of controllers defined in this module which
have to be instantiated
- Providers
- instantiated by the Nest injector and that may be
shared at least across this module
- Exports
- the subset of providers that are provided by this
module and should be available in other modules
- This helps us develop with SOLID principal
- https://www.membersedge.co.jp/blog/typescript-solid-si
ngle-responsibility-principle/
Provider
- https://docs.nestjs.com/providers
- services, repositories, factories, helpers, and so on
- The main idea of a provider is that it can be injected as a dependency
- objects can create various relationships with each other
- the function of "wiring up" instances of objects can largely be delegated to the Nest runtime system.
- Must read
- https://angular.io/guide/dependency-injection
- Essence
- Dependencies are clearly defined and the SOLID principle is easily satisfied.
- Singleton and managed by instances when needed.
- High performance and code readability
Dependency Injection
Custom Provider Feature
- https://docs.nestjs.com/fundamentals/custom-providers
Controller
- https://docs.nestjs.com/controllers
Guards
https://docs.nestjs.com/guards
- JWT token auth
- Role based auth
- etc.
- Interceptors
- https://docs.nestjs.com/interceptors
Interceptors/Pipes
- Pipes
- https://docs.nestjs.com/pipes
Serialization
- https://docs.nestjs.com/techniques/serialization
- You can easily specify which data to be exposed or not
Swagger
- https://github.com/nestjs/swagger
- https://docs.nestjs.com/techniques/database
- Nest is database agnostic, allowing you to easily integrate with any SQL or NoSQL database
- MikroORM
- Sequelize
- Knex.js
- TypeORM
- Prisma
- Mongoose
Database
Other features
- CLI
- WebSocket
- Config
- ORM
- Security
- GraphQL
- Micro Service
- etc..
Example Project
Demo
Summary
- A concise and clean implementation can be achieved by following the Nest.js
architecture
- In particular, the combined swagger-based/E2E development style is highly
recommended
- It is very efficient!

More Related Content

Nest.js Introduction