v2.1
This commit is contained in:
@@ -52,6 +52,10 @@ app.use('/admin', adminRouter);
|
||||
app.use('/ceo', ceoRouter);
|
||||
app.use('/backup_schemes', backupSchemesRouter);
|
||||
|
||||
app.use('/heartbeat', (req, res) => {
|
||||
return res.status(200).json({message: 'Server ap and running.'});
|
||||
})
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Server running on http://localhost:${port}`);
|
||||
});
|
||||
|
||||
@@ -1 +1,12 @@
|
||||
{}
|
||||
{
|
||||
"7c0ef9d5-23ed-47a6-bfb4-fdcfce436904": {
|
||||
"ip": "192.168.0.195",
|
||||
"directoryStructure": "{\"backup_dir\":{\"files\":[],\"fisiere\":{\"files\":[\"New Microsoft Excel Worksheet.xlsx\",\"New Microsoft Word Document.docx\"]}}}",
|
||||
"totalSize": 19363
|
||||
},
|
||||
"59c712d9-e6dd-438f-aec9-31ca2ae750e6": {
|
||||
"ip": "192.168.0.195",
|
||||
"directoryStructure": "{\"backup_dir\":{\"files\":[],\"fisiere\":{\"files\":[\"New Microsoft Excel Worksheet.xlsx\",\"New Microsoft Word Document.docx\"]}}}",
|
||||
"totalSize": 19363
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user