Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@nestjs/config
Advanced tools
The @nestjs/config package is a configuration solution for NestJS applications. It allows developers to load and use configuration variables in a structured and scalable way. The package supports loading configuration from environment variables and custom configuration files, making it easier to manage application settings across different environments.
Environment Variables Loading
This feature allows the application to load configuration variables from environment variables. The `forRoot` method can be used to customize the behavior, such as specifying a custom env file path.
import { ConfigModule } from '@nestjs/config';
@Module({
imports: [ConfigModule.forRoot()],
})
export class AppModule {}
Custom Configuration Files
This feature enables the application to load configuration settings from custom files. Developers can define a configuration file that exports a configuration object and load it using the `load` option.
import { ConfigModule } from '@nestjs/config';
import configuration from './config/configuration';
@Module({
imports: [
ConfigModule.forRoot({
load: [configuration],
}),
],
})
export class AppModule {}
Typed Configuration
This feature allows accessing configuration variables with type safety. The `ConfigService`'s `get` method can be used to retrieve configuration variables, optionally specifying the expected type.
import { ConfigService } from '@nestjs/config';
@Injectable()
class SomeService {
constructor(private configService: ConfigService) {}
someMethod() {
const dbUser = this.configService.get<string>('DATABASE_USER');
}
}
dotenv is a popular package for loading environment variables from a `.env` file into `process.env`. Unlike @nestjs/config, dotenv does not provide built-in support for NestJS modules or services, making it less integrated for NestJS applications but more versatile for other Node.js projects.
The `config` package allows managing configuration files in Node.js applications. It supports loading configurations from files based on the deployment environment. While it offers a structured approach to configuration management, it lacks the deep integration and features specifically designed for NestJS applications provided by @nestjs/config.
convict extends the basic configuration management by adding schema definitions, environment variables support, and validation. It's more comparable to @nestjs/config in terms of functionality but is not tailored specifically for NestJS, requiring more setup for use in NestJS applications.
A progressive Node.js framework for building efficient and scalable server-side applications.
Configuration module for Nest based on the dotenv (to load process environment variables) package.
$ npm i --save @nestjs/config
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
Nest is MIT licensed.
FAQs
Nest - modern, fast, powerful node.js web framework (@config)
The npm package @nestjs/config receives a total of 1,725,415 weekly downloads. As such, @nestjs/config popularity was classified as popular.
We found that @nestjs/config demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.