
Configuration & Environment Management
ConfigModule, environment variables, .env, secrets, multi-env (dev/staging/prod), feature flags
1What is the ConfigModule in NestJS?
What is the ConfigModule in NestJS?
Câu trả lời
ConfigModule is an official NestJS module that centralizes application configuration management. It allows loading environment variables from .env files, validating them with schemas, and injecting them into services via ConfigService. Unlike direct access to process.env, it provides strong typing and facilitates unit testing.
2How to import ConfigModule in a NestJS application?
How to import ConfigModule in a NestJS application?
Câu trả lời
ConfigModule is imported with ConfigModule.forRoot() in the root module (AppModule). This method automatically loads the .env file from the project root and makes ConfigService globally available. It's also possible to pass options like envFilePath to specify a custom path or isGlobal to avoid reimporting the module.
3What is the role of the .env file in a Node.js application?
What is the role of the .env file in a Node.js application?
Câu trả lời
The .env file stores environment-specific variables for each environment (development, staging, production). It contains values like database URLs, API keys, and secrets. This file should never be committed to Git (added to .gitignore) to avoid exposing sensitive information. It's loaded at startup via libraries like dotenv.
How to access an environment variable with ConfigService?
Which library does NestJS use to load .env files?
+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
NestJS Modules & DI
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í