Photo by Eric Er on Unsplash

Article

Configuration in NestJS

@nestjs/config loads environment variables and .env files into an injectable ConfigService. This chapter covers loading and precedence, namespaced and typed configuration, failing fast on missing values, and giving each feature module only the settings it needs.

Article

Dynamic modules in NestJS

forRoot(), forFeature(), and forRootAsync() are how NestJS modules accept options from the application that imports them. This chapter shows what a dynamic module returns, the naming conventions, async configuration through the injector, and generating the boilerplate with ConfigurableModuleBuilder.

Article

Application lifecycle hooks in NestJS

NestJS calls methods on your providers at fixed points while the application starts and stops. This chapter lists the hooks and their order, shows where startup work and cleanup belong, and explains why shutdown hooks have to be switched on before a container stop is handled gracefully.

Article

MongoDB with Mongoose in NestJS

@nestjs/mongoose wraps Mongoose in a dynamic module, so a connection is configured once and models are injected like any provider. This chapter connects with settings from ConfigService, defines a schema with decorators, and builds a service around an injected model.

Tags

Search articles

Type a word to search published articles.

Open the search page