@polls-platform/core
Version:
Polls Platform core library
28 lines (27 loc) • 1.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.initializePolls = void 0;
const error_1 = require("../error");
const types_1 = require("../types");
const config_1 = require("../config");
/* ****************************************************************************************************************** */
// region: Utils
/* ****************************************************************************************************************** */
/**
* Initialize the Polls SDK.
* Must be performed before interacting with the SDK.
* Any attempts to interact with the SDK before initializing will result
* in an error thrown.
* The SDK can be initialized multiple times and will always used the latest config.
* @category 1. Initialization
* @param config
*/
function initializePolls(config) {
const parseResult = types_1.Config.safeParse(config);
if (!parseResult.success) {
throw (0, error_1.createError)(error_1.ErrorMessage.BAD_CONFIG);
}
(0, config_1.setConfig)(parseResult.data);
}
exports.initializePolls = initializePolls;
// endregion