use dyetty instead of chalk
This commit is contained in:
parent
58f5afdfcb
commit
c89d3db1ed
2 changed files with 12 additions and 12 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1 +1 @@
|
||||||
EUS/
|
testing/
|
22
EUS.js
22
EUS.js
|
@ -76,7 +76,7 @@ class Database {
|
||||||
let dbConnection;
|
let dbConnection;
|
||||||
function init() {
|
function init() {
|
||||||
// Require node modules
|
// Require node modules
|
||||||
node_modules["chalk"] = require("chalk");
|
node_modules["dyetty"] = require("dyetty");
|
||||||
node_modules["busboy"] = require("connect-busboy");
|
node_modules["busboy"] = require("connect-busboy");
|
||||||
node_modules["randomstring"] = require("randomstring");
|
node_modules["randomstring"] = require("randomstring");
|
||||||
node_modules["streamMeter"] = require("stream-meter");
|
node_modules["streamMeter"] = require("stream-meter");
|
||||||
|
@ -249,7 +249,7 @@ function fileExists(file) {
|
||||||
function sendFile(req, res, path, startTime) {
|
function sendFile(req, res, path, startTime) {
|
||||||
// File does exist, send it back to the client.
|
// File does exist, send it back to the client.
|
||||||
res.sendFile(path);
|
res.sendFile(path);
|
||||||
global.modules.consoleHelper.printInfo(emoji.heavy_check, `${req.method}: ${node_modules.chalk.green("[200]")} ${req.url} ${Date.now() - startTime}ms`);
|
global.modules.consoleHelper.printInfo(emoji.heavy_check, `${req.method}: ${node_modules.dyetty.green("[200]")} ${req.url} ${Date.now() - startTime}ms`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function regularFile(req, res, urs = "", startTime) {
|
async function regularFile(req, res, urs = "", startTime) {
|
||||||
|
@ -275,14 +275,14 @@ async function regularFile(req, res, urs = "", startTime) {
|
||||||
if (!isSuccess) {
|
if (!isSuccess) {
|
||||||
// Doesn't exist, send a 404 to the client.
|
// Doesn't exist, send a 404 to the client.
|
||||||
await error404Page(res);
|
await error404Page(res);
|
||||||
global.modules.consoleHelper.printInfo(emoji.cross, `${req.method}: ${node_modules.chalk.red("[404]")} ${req.url} ${Date.now() - startTime}ms`);
|
global.modules.consoleHelper.printInfo(emoji.cross, `${req.method}: ${node_modules.dyetty.red("[404]")} ${req.url} ${Date.now() - startTime}ms`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function imageFile(req, res, file, startTime = 0) {
|
function imageFile(req, res, file, startTime = 0) {
|
||||||
res.sendFile(`${__dirname}${BASE_PATH}/i/${file}`);
|
res.sendFile(`${__dirname}${BASE_PATH}/i/${file}`);
|
||||||
global.modules.consoleHelper.printInfo(emoji.heavy_check, `${req.method}: ${node_modules.chalk.green("[200]")} (ImageReq) ${req.url} ${Date.now() - startTime}ms`);
|
global.modules.consoleHelper.printInfo(emoji.heavy_check, `${req.method}: ${node_modules.dyetty.green("[200]")} (ImageReq) ${req.url} ${Date.now() - startTime}ms`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function doImageLookup(req, res, urs, startTime) {
|
async function doImageLookup(req, res, urs, startTime) {
|
||||||
|
@ -471,7 +471,7 @@ async function handleAPI(req, res) {
|
||||||
// Status check to see the online status of EUS
|
// Status check to see the online status of EUS
|
||||||
// Used by ESL to make sure EUS is online
|
// Used by ESL to make sure EUS is online
|
||||||
case "/api/get-server-status":
|
case "/api/get-server-status":
|
||||||
global.modules.consoleHelper.printInfo(emoji.heavy_check, `${req.method}: ${node_modules.chalk.green("[200]")} (APIReq) ${req.url} ${Date.now() - startTime}ms`);
|
global.modules.consoleHelper.printInfo(emoji.heavy_check, `${req.method}: ${node_modules.dyetty.green("[200]")} (APIReq) ${req.url} ${Date.now() - startTime}ms`);
|
||||||
return res.end('{"status":1,"version":"'+global.internals.version+'"}');
|
return res.end('{"status":1,"version":"'+global.internals.version+'"}');
|
||||||
|
|
||||||
/* Stats api endpoint
|
/* Stats api endpoint
|
||||||
|
@ -488,34 +488,34 @@ async function handleAPI(req, res) {
|
||||||
if (filesaa == 1) {
|
if (filesaa == 1) {
|
||||||
// If getting the space used on the server isn't required send the json
|
// If getting the space used on the server isn't required send the json
|
||||||
if (spaceaa != 1) {
|
if (spaceaa != 1) {
|
||||||
global.modules.consoleHelper.printInfo(emoji.heavy_check, `${req.method}: ${node_modules.chalk.green("[200]")} (APIReq) ${req.url} ${Date.now() - startTime}ms`);
|
global.modules.consoleHelper.printInfo(emoji.heavy_check, `${req.method}: ${node_modules.dyetty.green("[200]")} (APIReq) ${req.url} ${Date.now() - startTime}ms`);
|
||||||
delete jsonaa["space"];
|
delete jsonaa["space"];
|
||||||
return res.end(JSON.stringify(jsonaa));
|
return res.end(JSON.stringify(jsonaa));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Getting space is required
|
// Getting space is required
|
||||||
if (spaceaa == 1) {
|
if (spaceaa == 1) {
|
||||||
global.modules.consoleHelper.printInfo(emoji.heavy_check, `${req.method}: ${node_modules.chalk.green("[200]")} (APIReq) ${req.url} ${Date.now() - startTime}ms`);
|
global.modules.consoleHelper.printInfo(emoji.heavy_check, `${req.method}: ${node_modules.dyetty.green("[200]")} (APIReq) ${req.url} ${Date.now() - startTime}ms`);
|
||||||
if (filesaa != 1) delete jsonaa["files"];
|
if (filesaa != 1) delete jsonaa["files"];
|
||||||
return res.end(JSON.stringify(jsonaa));
|
return res.end(JSON.stringify(jsonaa));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filesaa != 1 && spaceaa != 1) {
|
if (filesaa != 1 && spaceaa != 1) {
|
||||||
global.modules.consoleHelper.printInfo(emoji.heavy_check, `${req.method}: ${node_modules.chalk.green("[200]")} (APIReq) ${req.url} ${Date.now() - startTime}ms`);
|
global.modules.consoleHelper.printInfo(emoji.heavy_check, `${req.method}: ${node_modules.dyetty.green("[200]")} (APIReq) ${req.url} ${Date.now() - startTime}ms`);
|
||||||
return res.end("Please add f and or s to your queries to get the files and space");
|
return res.end("Please add f and or s to your queries to get the files and space");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Information API
|
// Information API
|
||||||
case "/api/get-info":
|
case "/api/get-info":
|
||||||
global.modules.consoleHelper.printInfo(emoji.heavy_check, `${req.method}: ${node_modules.chalk.green("[200]")} (APIReq) ${req.url} ${Date.now() - startTime}ms`);
|
global.modules.consoleHelper.printInfo(emoji.heavy_check, `${req.method}: ${node_modules.dyetty.green("[200]")} (APIReq) ${req.url} ${Date.now() - startTime}ms`);
|
||||||
return res.end(JSON.stringify({
|
return res.end(JSON.stringify({
|
||||||
version: global.internals.version,
|
version: global.internals.version,
|
||||||
instance: config["server"]["instance_type"]
|
instance: config["server"]["instance_type"]
|
||||||
}));
|
}));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
global.modules.consoleHelper.printInfo(emoji.heavy_check, `${req.method}: ${node_modules.chalk.green("[200]")} (APIReq) ${req.url} ${Date.now() - startTime}ms`);
|
global.modules.consoleHelper.printInfo(emoji.heavy_check, `${req.method}: ${node_modules.dyetty.green("[200]")} (APIReq) ${req.url} ${Date.now() - startTime}ms`);
|
||||||
return res.send(`
|
return res.send(`
|
||||||
<h2>All currently avaliable api endpoints</h2>
|
<h2>All currently avaliable api endpoints</h2>
|
||||||
<a href="/api/get-server-status">/api/get-server-status</a>
|
<a href="/api/get-server-status">/api/get-server-status</a>
|
||||||
|
@ -545,6 +545,6 @@ async function spaceToLowest(spaceValue, includeStringValue) {
|
||||||
module.exports.MOD_FUNC = MODULE_FUNCTION;
|
module.exports.MOD_FUNC = MODULE_FUNCTION;
|
||||||
|
|
||||||
module.exports.REQUIRED_NODE_MODULES = [
|
module.exports.REQUIRED_NODE_MODULES = [
|
||||||
"chalk", "connect-busboy", "randomstring",
|
"dyetty", "connect-busboy", "randomstring",
|
||||||
"stream-meter", "mysql2"
|
"stream-meter", "mysql2"
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue