New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@homeofthings/nestjs-config

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@homeofthings/nestjs-config

HomeOfThings - NestJs config: a configuration service for NestJs based on 'node-config'

  • 2.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-90.91%
Maintainers
0
Weekly downloads
 
Created
Source

npm version Build Workflow Coverage Status DeepScan grade Known Vulnerabilities

PRs Welcome License

HomeOfThings - Config for NestJs

a configuration module for NestJS providing a ConfigurationService based on node-config

installation

npm install @homeofthings/nestjs-config

quick start

import module in AppModule by providing options synchronously

@Module({
  imports: [
    ConfigModule.forRoot(ConfigModule, {}),
  ],
})
export class AppModule {}

import module in AppModule by providing options asynchronously

@Module({
  imports: [
    ConfigModule.forRootAsync(ConfigModule, {
      imports: [], // optional
      useFactory: (): Promise<ConfigModuleOptions> =>
        Promise.resolve({
          // provide your options
        }),
      inject: [], // optional inject params for useFactory method
    }),
  ],
})
export class AppModule {}

using for bootstrapping

const configService = ConfigModule.createConfigService({});

...
bootstrap();

NOTE: if you decide to combine this method with the imports into AppModule from above, only the options given to the first method will be taken into account

read configuration values

using one of the methods provided by the ConfigService:

export declare class ConfigService {
  readonly configDirectory: string;
  readonly environment: string;

  constructor(_opts: ConfigModuleOptions);

  getConfig(key: string): object | undefined;
  reloadConfig(): void;

  getString(key: string, defaultValue: string): string;
  getNumber(key: string, defaultValue: number): number;
  getBoolean(key: string, defaultValue: boolean): boolean;
  getObject(key: string, defaultValue: object): object;

  // resolve path relative to config-directory
  getPath(key: string, defaultValue: string): string;

  getOptionalString(key: string): string | undefined;
  getOptionalNumber(key: string): number | undefined;
  getOptionalBoolean(key: string): boolean | undefined;
  getOptionalObject(key: string): object | undefined;

  // resolve path relative to config-directory
  getOptionalPath(key: string): string | undefined;
}

reload configuration on SIGHUP

process.on('SIGHUP', () => ConfigService.getInstance().reloadConfig());

RELEASE NOTES

CHANGELOG

Keywords

FAQs

Package last updated on 22 Dec 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc