export type ProviderCreator = import('../shared/jimpleFns').ProviderCreator; export type EnvironmentUtilsProviderOptions = { /** * The name that will be used to register an instance of * {@link EnvironmentUtils }. Its default value is * `environmentUtils`. */ serviceName: string; }; /** * @module node/environmentUtils */ /** * @typedef {import('../shared/jimpleFns').ProviderCreator} ProviderCreator * @template O */ /** * @typedef {Object} EnvironmentUtilsProviderOptions * @property {string} serviceName The name that will be used to register an instance of * {@link EnvironmentUtils}. Its default value is * `environmentUtils`. * @parent module:node/environmentUtils */ /** * A simple service to avoid calling `process.env` on multiples places of an app. * * @parent module:node/environmentUtils * @tutorial environmentUtils */ export class EnvironmentUtils { /** * The current `NODE_ENV`. If the variable is empty, the value will be `development`. * * @type {string} * @access protected * @ignore */ _env: string; /** * Whether or not the environment is production. * * @type {boolean} * @access protected * @ignore */ _production: boolean; /** * Checks whether an environment variable exists or not. * * @param {string} name The name of the variable. * @returns {boolean} */ exists(name: string): boolean; /** * Gets the value of an environment variable. * * @param {string} name The name of the variable. * @param {string} [defaultValue=''] A fallback value in case the variable is * `undefined`. * @param {boolean} [required=false] If the variable is required and `undefined`, it * will throw an error. * @returns {string} * @throws {Error} If `required` is set to `true` and the variable is `undefined`. */ get(name: string, defaultValue?: string, required?: boolean): string; /** * Sets the value of an environment variable. * * @param {string} name The name of the variable. * @param {string} value The value of the variable. * @param {string} [overwrite=false] If the variable already exists, the method won't * overwrite it, unless you set this parameter to * `true`. * @returns {boolean} Whether or not the variable was set. */ set(name: string, value: string, overwrite?: string): boolean; /** * Whether or not the environment is for development. * * @type {boolean} */ get development(): boolean; /** * The current `NODE_ENV`. If the variable is empty, the value will be `development`. * * @type {string} * @access protected * @ignore */ get env(): string; /** * Whether or not the environment is production. * * @type {boolean} * @access protected * @ignore */ get production(): boolean; } /** * The service provider to register an instance of {@link EnvironmentUtils} on the * container. * * @type {ProviderCreator} * @tutorial environmentUtils */ export const environmentUtils: ProviderCreator;