From a376c888d9103bab31dd50f6cb002cc88764ada6 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Thu, 25 Apr 2024 08:19:28 +0200 Subject: [PATCH] feat: mix yml with salix --- lib/model-loader.js | 5 +++++ lib/salix.js | 32 ++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/lib/model-loader.js b/lib/model-loader.js index b66ec70..c22aab7 100644 --- a/lib/model-loader.js +++ b/lib/model-loader.js @@ -20,6 +20,11 @@ module.exports = class ModelLoader { schemaMap, logMap }); + + if(!conf.logs ) conf.logs = {} + Object.keys(conf.logs??{}).length > 0 && console.warn('‼️ - Existen modelos NO exportados') + Object.assign(conf.logs, logs) + for (const logName in conf.logs) { const logConf = conf.logs[logName]; diff --git a/lib/salix.js b/lib/salix.js index df3cacd..be32d0b 100644 --- a/lib/salix.js +++ b/lib/salix.js @@ -12,34 +12,38 @@ module.exports = class Salix { } async fetch(path) { - let salixCall = await fetch(`${this.conf.salix.url}/${path}`, { - method: "GET", - }); - const response = JSON.parse(await salixCall.text()); - if (salixCall.status !== 200) { - console.error(response.error); - throw new Error(response.error.message); + try { + let salixCall = await fetch(`${this.conf.salix.url}/${path}`, { + method: "GET", + }); + const response = JSON.parse(await salixCall.text()); + if (salixCall.status !== 200) { + console.error(response.error); + throw new Error(response.error.message); + } + this._salixVersion = salixCall.headers.get("Salix-version"); + return response; + } catch (error) { + throw new Error(error.message); } - this._salixVersion = salixCall.headers.get("Salix-version"); - return response; } async getSalixVersion() { - log("CHECK VERSION"); + this.log("CHECK VERSION"); const salixVersion = await this.fetch("applications/version"); if (this._salixVersion !== salixVersion) fetch(); - log("VERSION CHECKED"); + this.log("VERSION CHECKED"); } async salixLogInfo() { - log("LOGINFO REQUEST"); + this.log("LOGINFO REQUEST"); let salixLogConfig = await this.fetch("schemas/logInfo"); - this._logInfo = [salixLogConfig]; + this._logInfo = salixLogConfig; - log("LOGINFO REQUESTED"); + this.log("LOGINFO REQUESTED"); } log(param) {