oops
This commit is contained in:
parent
9e23c68204
commit
2fe9efd36a
1 changed files with 69 additions and 30 deletions
39
EUS.js
39
EUS.js
|
@ -3,6 +3,7 @@ config = require("../config/config.json"),
|
||||||
chalk = require("chalk"),
|
chalk = require("chalk"),
|
||||||
busboy = require("connect-busboy"),
|
busboy = require("connect-busboy"),
|
||||||
randomstring = require("randomstring"),
|
randomstring = require("randomstring"),
|
||||||
|
getSize = require('get-folder-size'),
|
||||||
emoji = require("../misc/emoji_list.json");
|
emoji = require("../misc/emoji_list.json");
|
||||||
|
|
||||||
// Defines the function of this module
|
// Defines the function of this module
|
||||||
|
@ -75,8 +76,45 @@ module.exports = {
|
||||||
res - Response from server
|
res - Response from server
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
let isAPI = false;
|
||||||
|
|
||||||
if (req.query["stat"] == "get") return res.end('{ "status":1, "version":"'+global.internals.version+'" }');
|
if (req.query["stat"] == "get") return res.end('{ "status":1, "version":"'+global.internals.version+'" }');
|
||||||
|
|
||||||
|
if (req.url.split("?")[0] == "/api/get-stats") {
|
||||||
|
isAPI = true;
|
||||||
|
const filesaa = req.query["f"],
|
||||||
|
spaceaa = req.query["s"];
|
||||||
|
let jsonaa = {};
|
||||||
|
if (filesaa == 1) {
|
||||||
|
jsonaa["files"] = {};
|
||||||
|
for (var i2 = 0; i2 < eusConfig.acceptedTypes.length; i2++) {
|
||||||
|
jsonaa["files"][`${eusConfig.acceptedTypes[i2]}`.replace(".", "")] = 0;
|
||||||
|
}
|
||||||
|
fs.readdir(__dirname + BASE_PATH + "/i", (err, files) => {
|
||||||
|
if (err) throw err;
|
||||||
|
for (var i = 0; i < files.length; i++) {
|
||||||
|
for (var i1 = 0; i1 < eusConfig.acceptedTypes.length; i1++) {
|
||||||
|
const jsudfg = files[i].split(".");
|
||||||
|
if (`.${jsudfg[jsudfg.length-1]}` == eusConfig.acceptedTypes[i1]) {
|
||||||
|
jsonaa["files"][eusConfig.acceptedTypes[i1].replace(".", "")]++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (spaceaa != 1) return res.end(JSON.stringify(jsonaa));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (spaceaa == 1) {
|
||||||
|
jsonaa["used"] = "";
|
||||||
|
getSize(__dirname + BASE_PATH + "/i", (err, size) => {
|
||||||
|
if (err) throw err;
|
||||||
|
const sizeOfFolder = (size / 1024 / 1024 / 1024).toFixed(2);
|
||||||
|
jsonaa["used"] = `${sizeOfFolder} GB`;
|
||||||
|
return res.end(JSON.stringify(jsonaa));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isAPI) {
|
||||||
// Register the time at the start of the request
|
// Register the time at the start of the request
|
||||||
d = new Date();
|
d = new Date();
|
||||||
startTime = d.getTime();
|
startTime = d.getTime();
|
||||||
|
@ -110,6 +148,7 @@ module.exports = {
|
||||||
global.modules.consoleHelper.printInfo(emoji.heavy_check, `${req.method}: ${chalk.green("[200]")} ${req.url} ${endTime - startTime}ms`);
|
global.modules.consoleHelper.printInfo(emoji.heavy_check, `${req.method}: ${chalk.green("[200]")} ${req.url} ${endTime - startTime}ms`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
post:function(req, res) {
|
post:function(req, res) {
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue