import { DotenvConfigOptions } from 'dotenv'; /** * Add a couple of options to the default config options' interface. */ export interface DotenvConfig extends DotenvConfigOptions { cwd?: string; glob?: string; defaultNodeEnv?: string; } export interface ModuleConfig { [key: string]: any; } export interface Config { [key: string]: ModuleConfig; } export declare type CustomHelper = { [key: string]: (...args: any[]) => any; }; export declare class ConfigService { [key: string]: Config | CustomHelper | ((...args: any[]) => any) | any; private static config; private readonly helpers; protected static defaultGlob: string; static srcPath?: string; /** * @param {Config} config */ constructor(config?: Config); /** * Load configuration from file system * @param glob string * @param {DotenvConfig} options * @returns {Promise} */ static load(globOrOptions?: string | DotenvConfig | false, options?: DotenvConfig | false): Promise; /** * Load config synchronously * @param {string} glob * @param {DotenvConfig | false} options */ static loadSync(glob: string, options?: DotenvConfig | false): ConfigService; /** * Get the param or use default * * @param {String} key * @param {any} value default * @returns {any|undefined} */ static get(param: string | string[], value?: any): any; /** * Get the param or use default * * @param param * @param {any} value default * @returns {any} */ get(param: string | string[], value?: any): any; /** * Set config value at runtime * @param {string} param * @param value * @returns {Config} */ set(param: string | string[], value?: any): Config; /** * Check the param exists * * @param param * @returns {boolean} */ has(param: string | string[]): boolean; /** * Merge configuration * @param glob * @param options */ merge(glob: string, options?: DotenvConfig): Promise; /** * Merge configuration synchronously * @param {string} glob * @param {DotenvConfig} options * @returns {ConfigService} */ mergeSync(glob: string, options?: DotenvConfig): ConfigService; /** * @param {string} name * @param {CustomHelper} fn * @returns {ConfigService} */ registerHelper(name: string, fn: (...args: any[]) => any): ConfigService; /** * @param {string} dir * @returns {string} */ static root(dir?: string): string; /** * @param {string} dir * @returns {string} */ static src(dir?: string): string; /** * Resolves and stores sources directory for application. * @param {string} startPath * The path for search starting. Can be any path under app sources path. */ static resolveSrcPath(startPath: string): typeof ConfigService; /** * @param {string | string[]} glob * @param {DotenvConfig | false} options * @returns {Promise} */ protected static loadConfigAsync(glob: string, options?: DotenvConfig | false): Promise; /** * Load config synchronously * @param {string} glob * @param {DotenvConfig | false} options * @returns {Config} */ protected static loadConfigSync(glob: string, options?: DotenvConfig | false): Config; /** * Config graph from an array of paths * @param configPaths * @returns {any} */ protected static configGraph(configPaths: string[]): {}; /** * @param config * @returns {string} */ protected bindCustomHelpers(config: any): any; /** * Get config name from a file path * @param {string} file * @returns {string} */ protected static getConfigName(file: string): string; /** * Loads env variables via dotenv. * @param {DotenvConfig | false} options */ protected static loadEnv(options?: DotenvConfig | false): void; /** * Default dotenv config point to a .env * on the cwd path * @returns {{path: string}} */ protected static defaultDotenvConfig(): { cwd: string; defaultNodeEnv: string; }; }