
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
nestjs-config-module
Advanced tools
Configuration module for Nest framework (node.js)
npm install --save nestjs-config-module
You have to import the Module ConfigModule and initialize it with the forRoot function, this fetches a Javascript object with the loader function, then maps and validates that to the schema
This Module is not used as injection dependency directly, but rather its schema class and subclasses.
import { Module } from '@nestjs/common';
import { ConfigModule, envJsonLoaderFactory } from 'nestjs-config-module';
import { IsOptional, ValidateNested, IsArray, ArrayUnique, IsString, IsIn } from 'class-validator';
import { Type } from 'class-transformer';
import { LogLevel } from "@nestjs/common";
export class LogConfiguration {
@IsArray()
@ArrayUnique()
@IsString({
each: true
})
@IsIn(['log', 'error', 'warn', 'debug', 'verbose'], {
each: true
})
levels: LogLevel[] = ['log', 'error', 'warn'];
}
export class Configuration {
@IsOptional()
host?: string;
@ValidateNested() @Type(() => LogConfiguration)
log = new LogConfiguration();
}
@Module({
imports: [ConfigModule.forRoot({
isGlobal: true,
loader: envJsonLoaderFactory('DEMO_'),
schema: Configuration,
})],
})
export class AppModule {}
import { Injectable } from '@nestjs/common';
import { Configuration } from 'app.module';
@Injectable()
export class FooService {
constructor(
private configuration: Configuration,
) {}
}
import { Injectable } from '@nestjs/common';
import { LogConfiguration } from 'app.module';
@Injectable()
export class BarService {
constructor(
private logConfiguration: LogConfiguration,
) {}
}
this module comes with 2 builtin loaders:
For the documentation on how to use the envJsonLoader see: env-json-parser
It's also possible to implement your own loader, it just needs to be a function that returns a Promise which resolves an object
ConfigModule.forRoot({
isGlobal: true,
loader: (): Promise<object> => {
return Promise.resolve({
host: 'localhost'
})
},
schema: Configuration,
})
FAQs
Configuration module for Nest framework (node.js)
The npm package nestjs-config-module receives a total of 4 weekly downloads. As such, nestjs-config-module popularity was classified as not popular.
We found that nestjs-config-module demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.