@adonisjs/config
Version:
Config collection and loader used by the AdonisJS framework
36 lines (35 loc) • 799 B
JavaScript
import lodash from "@poppinss/utils/lodash";
import { fsImportAll } from "@poppinss/utils/fs";
var Config = class {
#config;
constructor(config = {}) {
this.#config = config;
}
all() {
return this.#config;
}
has(key) {
return lodash.has(this.#config, key);
}
get(key, defaultValue) {
return lodash.get(this.#config, key, defaultValue);
}
defaults(key, value) {
const existingValue = this.get(key);
if (existingValue !== void 0) lodash.mergeWith(value, existingValue);
this.set(key, value);
}
set(key, value) {
lodash.set(this.#config, key, value);
}
};
var ConfigLoader = class {
#configDir;
constructor(configDir) {
this.#configDir = configDir;
}
load() {
return fsImportAll(this.#configDir, { ignoreMissingRoot: true });
}
};
export { Config, ConfigLoader };