NestJS 11 · Controllers, providers and modules
Load configuration
Make environment variables available everywhere, then inject ConfigService.
ConfigModule.forRoot({ isGlobal: true })
// in a service
constructor(private config: ConfigService) {}
const port = this.config.get<number>('PORT', 3000);
Official NestJS 11 documentation
More controllers, providers and modules commands
- Write a controller
- Write a provider (service)
- Wire things together in a module
- Provide a value or factory
All controllers, providers and modules commands · NestJS 11 cheatsheet