Refactored server to handle new JSON post requests

This commit is contained in:
YourFriendlyNeighborhoodDealer 2018-12-14 18:32:04 +01:00
parent 0f71d6705b
commit 3c0e593ed4
3 changed files with 284 additions and 24 deletions

View file

@ -15,6 +15,7 @@ const recievedFile = "stats/recieved";
const staticFile = "public/data/static";
const manFile = "public/man.html";
const logFile = "stats/logs";
const dataFile = "public/data.json";
function ReadFile(name) {
return fs.readFileSync(name, "utf8");
@ -56,4 +57,12 @@ function WriteBackup() {
logger.Log("[ERR ]: Error backing up recieved file!", logger.GetColor("redbg"));
console.log(e);
}
try {
WriteFileAsync(ReadFile(dataFile), 'public/backs/data_' + new Date().toString());
} catch (e) {
logger.Log("[ERR ]: Error backing up data json file!", logger.GetColor("redbg"));
console.log(e);
}
}