Nest JS Architecture
Client Server Architecture
in client server architecture client send request to the server and server process the request and send back response to the client.
Nest js Architecture
Controllers
Controllers responsible to handle request.it has multiple request handler attached for different requestes.
Services
All the business logic is present here.it's responsible for communicating with database. and after process it sends data to the controller then controller send response to the client.
There are 4 types of scope
Global Scope
Module Scope
Controller Scope
Request Handle/Route Scope
Middleware
it's executed before reaching request to the controller.if you want manipulate request object you can do it there. we can add middleware at global scope, controller scope, Request handler scope.
Guard
it's responsible to check is request should be process or not. we use this for validation of user is user authenticated or not.
Pipe
if you want to transform or validate request object you can use pipe in nest js.
Interceptor
it's similar to middleware but executed both request and response time.
Exception Filter
if any error occurs at application it is handled by Exception filter at global level.
Order of excution
Middleware
Guards
Interceptor
Pipe