UNPKG

@villedemontreal/jwt-validator

Version:
47 lines 1.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.init = init; exports.isInited = isInited; const http_request_1 = require("@villedemontreal/http-request"); const configs_1 = require("./configs"); const constants_1 = require("./constants"); let libIsInited = false; /** * Inits the library. */ function init(loggerCreator, correlationIdProvider, host, endpoint = constants_1.constants.default.endpoint, fetchKeysParameters = constants_1.constants.default.fetchKeysParameters, cacheDuration = constants_1.constants.default.cacheDuration, urlCaseSensitive = false) { if (!loggerCreator) { throw new Error(`The Logger Creator is required.`); } configs_1.configs.setLoggerCreator(loggerCreator); if (!correlationIdProvider) { throw new Error(`The Correlation Id provider is required.`); } configs_1.configs.setCorrelationIdProvider(correlationIdProvider); configs_1.configs.setHost(host); configs_1.configs.setEndpoint(endpoint); configs_1.configs.setFetchKeysParameters(fetchKeysParameters); configs_1.configs.setCacheDuration(cacheDuration); // ========================================== // Inits the Http Utils library! // ========================================== (0, http_request_1.init)(loggerCreator, correlationIdProvider, urlCaseSensitive); // ========================================== // Set as being "properly initialized". // At the very end of the "init()" function! // ========================================== libIsInited = true; } /** * Is the library properly initialized? * * This function MUST be named "isInited()"! * Code using this library may loop over all its "@villedemontreal" * dependencies and, if one of those exports a "isInited" fonction, * it will enforce that the lib has been properly initialized before * starting... */ function isInited() { return libIsInited; } //# sourceMappingURL=init.js.map