UNPKG

@homeofthings/node-utils

Version:

HomeOfThings - Node Utils: various utilities and common types

87 lines (86 loc) 3.15 kB
import { ConfigOptions } from './config.options'; /** ConfigService to read configured values. */ export declare class ConfigService { private _opts; static readonly DEFAULT_ENV = "development"; private static _instance; readonly configDirectory: string; readonly environment: string; get opts(): ConfigOptions; constructor(_opts: ConfigOptions); private getValue; /** * @description get immutable config * NOTE: consider using `getOptionalObject` to get the corresponding mutable object * @param key - the configuration key * @return {object|undefined} */ getConfig(key: string): object | undefined; reloadConfig(): void; /** * @description get a string * @param key - the configuration key * @param defaultValue - the default value to use if key is not configured * @return {string|undefined} */ getString(key: string, defaultValue: string): string; /** * @description get a number * @param key - the configuration key * @param defaultValue - the default value to use if key is not configured * @return {number|undefined} */ getNumber(key: string, defaultValue: number): number; /** * @description get a boolean * @param key - the configuration key * @param defaultValue - the default value to use if key is not configured * @return {boolean|undefined} */ getBoolean(key: string, defaultValue: boolean): boolean; /** * @description get an object * @param key - the configuration key * @param defaultValue - the default value to use if key is not configured * @return {object|undefined} */ getObject(key: string, defaultValue: object): object; /** * @description resolves an file or directory path relative to the config directory * @param key - the configuration key * @param defaultValue - the default value to use if key is not configured * @return {string|undefined} the resulting path */ getPath(key: string, defaultValue: string): string; /** * @description get optional string * @param key - the configuration key * @return {string|undefined} */ getOptionalString(key: string): string | undefined; /** * @description get optional number * @param key - the configuration key * @return {number|undefined} */ getOptionalNumber(key: string): number | undefined; /** * @description get optional boolean * @param key - the configuration key * @return {boolean|undefined} */ getOptionalBoolean(key: string): boolean | undefined; /** * @description get optional cloned object * @param key - the configuration key * @return {object|undefined} */ getOptionalObject(key: string): object | undefined; /** * @description resolves an optional file or directory path relative to the config directory * @param key - the configuration key * @return {string|undefined} the resulting path */ getOptionalPath(key: string): string | undefined; static getInstance(): ConfigService; }