44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
|
module.exports = class Salix {
|
||
|
constructor() {
|
||
|
this.conf = null;
|
||
|
this._logInfo = [];
|
||
|
this._salixVersion = null;
|
||
|
}
|
||
|
async init(logger) {
|
||
|
|
||
|
this.conf = logger.conf;
|
||
|
|
||
|
setInterval(() => this.getSalixVersion, this.conf.salix.renewInterval);
|
||
|
await this.salixLogInfo();
|
||
|
}
|
||
|
|
||
|
async getSalixVersion(){
|
||
|
console.log("SALIX - CHECK VERSION");
|
||
|
let salixCall = await fetch(`${this.conf.salix.url}/applications/version`, {
|
||
|
method: "GET",
|
||
|
});
|
||
|
let salixVersion = JSON.parse(await salixCall.text());
|
||
|
console.log("SALIX - VERSION CHECKED");
|
||
|
if(this._salixVersion !== salixVersion) fetch();
|
||
|
}
|
||
|
|
||
|
async salixLogInfo() {
|
||
|
console.log("SALIX - LOGINFO REQUEST");
|
||
|
let salixCall = await fetch(`${this.conf.salix.url}/schemas/logInfo`, {
|
||
|
method: "GET",
|
||
|
});
|
||
|
let salixLogConfig = [JSON.parse(await salixCall.text())];
|
||
|
this._salixVersion = salixCall.headers.get("Salix-version");
|
||
|
this._logInfo = salixLogConfig
|
||
|
console.log("SALIX- LOGINFO REQUESTED");
|
||
|
}
|
||
|
|
||
|
get logInfo(){
|
||
|
return this._logInfo
|
||
|
}
|
||
|
|
||
|
get salixVersion(){
|
||
|
return this._salixVersion;
|
||
|
}
|
||
|
};
|