Middle
What are the main components of NestJS?
sobes.tech AI
Answer from AI
Main components of NestJS:
- Modules: Organize application code into logical groups. Each module can export and import other modules.
- Controllers: Handle incoming requests and return responses. Define routes and bind them to class methods.
- Providers: Used for dependency injection. They can be services, repositories, factories, or any custom classes.
- Services: Encapsulate core business logic, accessible for use in controllers and other providers.
Also used:
- Middleware: Functions executed before route handlers. Used for authentication, logging, request and response modification.
- Pipes: Transform and validate incoming data.
- Guards: Determine if a user has access to a specific route or resource.
- Interceptors: Allow attaching additional logic before and after method execution, such as transforming results or handling exceptions.
- Exception Filters: Catch unhandled exceptions and send formatted responses to the client.