mirror of
https://github.com/HirziDevs/PteroStats
synced 2026-01-08 07:11:48 +00:00
28 lines
1.1 KiB
JavaScript
28 lines
1.1 KiB
JavaScript
const cliColor = require("cli-color");
|
|
const yaml = require("js-yaml");
|
|
const fs = require("node:fs");
|
|
|
|
console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.yellow("Loading configuration..."));
|
|
|
|
let config = yaml.load(fs.readFileSync("./config.yml", "utf8"));
|
|
if (fs.existsSync("config-dev.yml")) {
|
|
console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.yellow("Using development configuration..."));
|
|
config = yaml.load(fs.readFileSync("./config-dev.yml", "utf8"));
|
|
}
|
|
|
|
try {
|
|
const testURL = new URL(process.env?.PanelURL);
|
|
if (!testURL.protocol.startsWith("http")) throw new Error();
|
|
} catch {
|
|
console.error('Config Error | Invalid URL Format! Example Correct URL: "https://panel.example.com"');
|
|
process.exit();
|
|
}
|
|
|
|
if (config.version !== 9) {
|
|
console.error('Config Error | Invalid config version! The config has been updated. Please get the new config format from: \n>> https://github.com/HirziDevs/PteroStats/blob/main/config.yml <<');
|
|
process.exit();
|
|
}
|
|
|
|
console.log(cliColor.cyanBright("[PteroStats] ") + cliColor.yellow("Configuration loaded"));
|
|
|
|
module.exports = config; |