DEV Community

Cover image for NestJS - overview
Ilya R
Ilya R

Posted on

NestJS - overview

NestJS is a backend framework on NodeJS. it developed by Kamil Mysliwiec.
NestJS defines the architecture of application and has many useful feature. It helps us in developing. We can write our code directly on TypeScript.

Structure of framework: modules, which contain controllers and services.

Modules.
Modules are individual parts of an application. They are like application entities. it is convenient to isolate the logic of individual pieces in a Module. This helps to easily add new features and functionality to the application. They are like a Namespaces.

Controllers.
Controllers are needed to create endpoints. They are like callback functions that are called on a specific URL. Methods of controllers called Actions. Well, in fact controllers dont contain a lot of logic. They usually call methods of models and services. Controllers help to separate application logic by URL.

Services.
Services contain all the main business logic of the application. Also, work with the database and third-party APIs. Services should include data processing an response formation. In other frameworks, they may be called Models.

Middleware.
Also, NestJS allows you to work with middleware. This is a special layer through which the request passes before being processed by the controller. Also, there is a middleware that is called after the controller returns a response to the user.

CLI.
NestJS has a handy CLI. It speeds up the development of the application and helps to create different files. For example, using the CLI, you can create models, controllers, and services.

Top comments (2)

Collapse
 
andrewbaisden profile image
Andrew Baisden

I have to say that I really enjoy using NestJS and I thought that I would just stick with Express.js forever. But NestJS has great documentation and it uses TypeScript first.

Collapse
 
thanhchuongdev profile image
thanhchuongbmd

TS.ED is easier