UNPKG

nest-simple-config

Version:

A powerful and flexible configuration management library for NestJS applications. Supports JSON, YAML file loading, environment variable overrides, immutable configurations, and type-safe configuration access with dependency injection.

24 lines (23 loc) 846 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FileConfigurationProvider = void 0; const fs_1 = require("fs"); const config_provider_abstract_1 = require("./config-provider.abstract"); class FileConfigurationProvider extends config_provider_abstract_1.ConfigurationProvider { constructor(filename, optional = false, fileLoader) { super(); this.filename = filename; this.optional = optional; this.fileLoader = fileLoader; } loadConfigObject() { if (!(0, fs_1.existsSync)(this.filename) && this.optional) { return {}; } return this.fileLoader(this.filename); } toString() { return `provider: ${this.constructor.name}, file: ${this.filename}`; } } exports.FileConfigurationProvider = FileConfigurationProvider;