@villedemontreal/http-request
Version:
HTTP utilities - send HTTP requests with proper headers, etc.
49 lines • 1.63 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.init = init;
exports.isInited = isInited;
const _ = require("lodash");
const configs_1 = require("./configs");
let libIsInited = false;
/**
* Inits the library.
*/
function init(loggerCreator, correlationIdProvider,
/**
* The case sensitivity to use for the URLs.
*
* In an API based on "@villemontreal/generator-mtl-node-api",
* you need to pass `configs.routing.caseSensitive` here!
*/
urlCaseSensitive) {
if (!loggerCreator) {
throw new Error(`The Logger Creator is required.`);
}
if (!correlationIdProvider) {
throw new Error(`The Correlation Id provider is required.`);
}
if (_.isNil(urlCaseSensitive)) {
throw new Error(`The Case Sensitivity to use for the URLs is required.`);
}
configs_1.configs.setLoggerCreator(loggerCreator);
configs_1.configs.setCorrelationIdProvider(correlationIdProvider);
configs_1.configs.setUrlCaseSensitive(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 "@villemontreal"
* 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