
NestJS Modules & DI
Modular architecture, imports/exports, forRoot/forFeature, dynamic modules, circular dependencies
1What is a module in NestJS?
What is a module in NestJS?
Câu trả lời
A module is a class annotated with the @Module() decorator that organizes code in a cohesive way. It encapsulates a set of providers, controllers, and other modules, allowing the application to be structured into modular components. Each NestJS application has at least one root module that serves as the entry point.
2What is the role of the 'providers' property in the @Module() decorator?
What is the role of the 'providers' property in the @Module() decorator?
Câu trả lời
The providers property declares services and other classes that can be injected by the Dependency Injection system. These providers are instantiated by the NestJS container and can be shared within the module. They represent the business logic of the application and are accessible via dependency injection.
3How to make a provider available to other modules?
How to make a provider available to other modules?
Câu trả lời
To make a provider accessible from other modules, it must be added to the exports array of the @Module() decorator. Only exported providers can be injected into other modules that import this module. This allows precise control over a module's public API and encapsulation of internal implementation.
What is the difference between 'imports' and 'exports' in a module?
What is Dependency Injection (DI) in NestJS?
+17 câu hỏi phỏng vấn
Các chủ đề phỏng vấn Node.js / NestJS khác
Node.js Fundamentals
Node.js Core APIs
Asynchronous Programming
Express.js Basics
NestJS Fundamentals
REST API Design
Validation & DTO
API Documentation & Contracts
Error Handling
Unit Testing
Task Scheduling
Configuration & Environment Management
JWT Authentication
Authorization & RBAC
Database with TypeORM
Prisma ORM
Middleware & Interceptors
File Upload
WebSockets
GraphQL with NestJS
End-to-End Testing
Caching with Redis
Queues with Bull
DevOps, Logging & CI/CD
Docker & Containerization
Microservices
Security Best Practices
Performance & Cloud Deployment
Nắm vững Node.js / NestJS cho lần phỏng vấn tiếp theo
Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.
Bắt đầu miễn phí