"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * get and set global Arc.js settings
 */
class ConfigService {
    static get(setting) {
        return ConfigService.data[setting];
    }
    static set(setting, value) {
        ConfigService.data[setting] = value;
    }
    constructor() {
        if (!ConfigService.instance) {
            const defaults = require("../config/default.json");
            const prefix = "arcjs_";
            if (process && process.env) {
                Object.keys(process.env).forEach((key) => {
                    if (key.startsWith(prefix)) {
                        const internalKey = key.replace(prefix, "");
                        if (defaults.hasOwnProperty(internalKey)) {
                            defaults[internalKey] = process.env[key];
                        }
                    }
                });
            }
            ConfigService.data = defaults;
            ConfigService.instance = this;
        }
        return ConfigService.instance;
    }
}
exports.ConfigService = ConfigService;
/**
 * This will automagically create a static instance of ConfigService that will be used whenever
 * someone imports ConfigService.
 */
Object.freeze(new ConfigService());
//# sourceMappingURL=configService.js.map