Refactor code :3

This commit is contained in:
Ashley 2023-06-04 14:11:41 +00:00
parent cc425b7b97
commit 63a60a7f41

View file

@ -12,41 +12,143 @@
*/ */
const fetcher = require("../libpoketube/libpoketube-fetcher.js");
const core = require("../libpoketube/libpoketube-core.js");
const musicInfo = require("music-info");
const wiki = require("wikipedia");
const fetch = require("node-fetch");
const toJson = require("xml2json").toJson;
const express = require("express");
const useragent = require("express-useragent");
const path = require("path");
const hash = require("js-sha512").sha384;
const moment = require("moment");
const getColors = require("get-image-colors");
/**
* Logs a message to the console with a specific prefix
*
* @param {string} args - The message to wood (get it log wood im so funny)
*/
function initlog(args) { function initlog(args) {
console.log("[LIBPT INTSYS] " + args) console.log("[LIBPT INTSYS] " + args);
} }
/**
* Initializes the application and starts listening on the specified port or something idk aaaaa help me
*
* @param {object} app - The express application
* @param {string} [port="3000"] - The port to listen on
*/
function init(app, port) { function init(app, port) {
if(!port) port = "3000" if (!port) port = "3000";
try { try {
app.listen(port, () => { app.listen(port, () => {
initlog("Loading Poketube: success!" + " on port " + port); initlog("Loading Poketube: success!" + " on port " + port);
}); });
} catch (err) { } catch (err) {
initlog("Loading Poketube: error", err); initlog("Loading Poketube: error", err);
} }
} }
module.exports =
{
fetcher:require("../libpoketube/libpoketube-fetcher.js"), module.exports = {
core:require("../libpoketube/libpoketube-core.js"), /**
musicInfo:require("music-info"), * The fetcher module
wiki:require("wikipedia"), * @type {object}
*/
fetcher,
/**
* The core module
* @type {object}
*/
core,
/**
* The musicInfo module
* @type {object}
*/
musicInfo,
/**
* The wiki module
* @type {object}
*/
wiki,
/**
* Logs a message to the console with a specific prefix
* @type {Function}
*/
initlog, initlog,
/**
* Initializes the application and starts listening on the specified port
* @type {Function}
*/
init, init,
/**
* The version of the LIB-PokeTube module
* @type {string}
*/
version: "libpoketube-3.1.1-git-aStfl", version: "libpoketube-3.1.1-git-aStfl",
/**
* The external modules used by PokeTube
* @type {object}
*/
modules: { modules: {
fetch:require("node-fetch"), /**
toJson:require("xml2json").toJson, * The fetch module
express:require("express"), * @type {object}
useragent:require("express-useragent"), */
path:require("path"), fetch,
hash:require("js-sha512").sha384,
moment:require("moment"), /**
getColors:require("get-image-colors"), * The toJson module
} * @type {Function}
*/
toJson,
/**
* The express module
* @type {object}
*/
express,
/**
* The useragent module
* @type {object}
*/
useragent,
/**
* The path module
* @type {object}
*/
path,
/**
* The hash module
* @type {Function}
*/
hash,
/**
* The moment module
* @type {object}
*/
moment,
/**
* The getColors module
* @type {Function}
*/
getColors,
} }
};