UNPKG

@polls-platform/core

Version:

Polls Platform core library

33 lines (32 loc) 1.31 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getConfig = exports.setConfig = void 0; const zod_1 = require("zod"); const error_1 = require("./error"); const types_1 = require("./types"); /* ****************************************************************************************************************** */ // region: Locals /* ****************************************************************************************************************** */ let currentConfig; const InternalConfig = zod_1.z.object({ apiKey: types_1.ApiKey, domainConfig: types_1.DomainConfig, environment: types_1.EnvironmentEnum.default(types_1.Environment.production), }); // endregion /* ****************************************************************************************************************** */ // region: Utils /* ****************************************************************************************************************** */ function setConfig(config) { // applies defaults currentConfig = InternalConfig.parse(config); } exports.setConfig = setConfig; function getConfig() { if (!currentConfig) { throw (0, error_1.createError)(error_1.ErrorMessage.INIT_REQUIRED); } return currentConfig; } exports.getConfig = getConfig; // endregion