This commit is contained in:
andrei-mihnea-cerbu
2024-04-22 16:30:40 +03:00
parent 7cf1729d08
commit 9ac718bea3
24 changed files with 275 additions and 163 deletions
+20 -1
View File
@@ -1,4 +1,23 @@
const express = require('express');
const checkForServerConnection = async () => {
const pathToIpConfig = path.join(__dirname, '..', '..', 'ipConfig.json');
await lockFile.lock(pathToIpConfig);
try {
await decryptFileInPlace(pathToIpConfig);
const ipConfig = await fs.readFile(pathToIpConfig, 'utf-8');
const { ip } = JSON.parse(ipConfig);
const response = await fetch(`http://${ip}:5000/heartbeat`);
if (response.ok) {
return true;
} else {
return false;
}
} catch (error) {
console.error("Error:", error);
return false;
} finally {
await lockFile.unlock(pathToIpConfig);
}
};const express = require('express');
const crypto = require('crypto');
const { v4: uuidv4 } = require('uuid');