diff --git a/.gitignore b/.gitignore
index 3b2f32d..8ba441d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,11 +1,7 @@
+/*.log
node_modules/
-GitMessage.txt
dist/
-*.tgz
-CHANGELOG.md
-*.env
-versions.json
-
-# Static files
-versions/
-!versions/index.html
\ No newline at end of file
+src/**/*.d.ts
+src/**/*.d.js
+src/**/*.js
+docs/
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
index c9782e7..7585918 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -6,7 +6,7 @@ ENV KEY="" CERT="" RUNNINGON="railway"
# Install basic files
RUN apt update && apt install -y wget curl chromium-browser && wget -qO- https://raw.githubusercontent.com/Sirherobrine23/DebianNodejsFiles/main/debianInstall.sh | bash
-ENTRYPOINT [ "node", "dist/api.js" ]
+ENTRYPOINT [ "node", "src/api.js" ]
COPY ./package*.json ./
RUN npm ci
COPY ./ ./
diff --git a/package.json b/package.json
index 1ac74d6..01daa0b 100644
--- a/package.json
+++ b/package.json
@@ -6,14 +6,14 @@
"private": false,
"author": "sirherobrine23",
"license": "MIT",
- "main": "dist/index.js",
- "types": "./dist/index.d.ts",
+ "main": "src/index.js",
+ "types": "./src/index.d.ts",
"type": "commonjs",
"publishConfig": {
"access": "public"
},
"bin": {
- "minecraft_version": "./dist/bin.js"
+ "minecraft_version": "./src/bin.js"
},
"scripts": {
"dev": "nodemon -e ts,js -w src/**/* src/api.ts",
diff --git a/src/api.d.ts b/src/api.d.ts
deleted file mode 100644
index cb0ff5c..0000000
--- a/src/api.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export {};
diff --git a/src/api.js b/src/api.js
deleted file mode 100644
index f765279..0000000
--- a/src/api.js
+++ /dev/null
@@ -1,90 +0,0 @@
-"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const node_https_1 = __importDefault(require("node:https"));
-const node_http_1 = __importDefault(require("node:http"));
-const yaml_1 = __importDefault(require("yaml"));
-const express_1 = __importDefault(require("express"));
-const cors_1 = __importDefault(require("cors"));
-// Db And routes
-const connect_1 = __importDefault(require("./db/connect"));
-const bedrock_1 = require("./db/bedrock");
-const java_1 = require("./db/java");
-const pocketmine_1 = require("./db/pocketmine");
-const spigot_1 = require("./db/spigot");
-const powernukkit_1 = require("./db/powernukkit");
-const paper_1 = require("./db/paper");
-const app = (0, express_1.default)();
-app.disable("x-powered-by");
-app.disable("etag");
-app.use((0, cors_1.default)());
-app.use((req, res, next) => {
- res.json = (body) => {
- var _a;
- const deleteKeys = ["__v", "_id"];
- if (body instanceof Array) {
- if (body[0] instanceof Object) {
- if (((_a = body[0]) === null || _a === void 0 ? void 0 : _a.date) instanceof Date)
- body = body.sort((b, a) => { var _a, _b; return ((_a = a.date) === null || _a === void 0 ? void 0 : _a.getTime()) - ((_b = b.date) === null || _b === void 0 ? void 0 : _b.getTime()); });
- }
- }
- body = JSON.parse(JSON.stringify(body, (key, value) => deleteKeys.includes(key) ? undefined : value));
- if (req.query.type === "yaml" || req.query.type === "yml")
- return res.setHeader("Content-Type", "text/yaml").send(yaml_1.default.stringify(body));
- return res.set("Content-Type", "application/json").send(JSON.stringify(body, (_, value) => typeof value === "bigint" ? value.toString() : value, 2));
- };
- return next();
-});
-// Ping
-app.all("/ping", ({ res }) => res.status(200).json({ status: "Ok", from: process.env.RUNNINGON || "unknown" }));
-app.all(/^\/favicon.*/, ({ res }) => res.redirect("https://raw.githubusercontent.com/The-Bds-Maneger/Bds-Maneger-html-assets/main/images/mcpe.ico"));
-// Listen server
-connect_1.default.once("connected", () => {
- // Listen ports
- const portsListen = { http: process.env.PORT || 8080, https: process.env.PORTS || 8443 };
- node_http_1.default.createServer(app).listen(portsListen.http, () => console.log("(HTTP) Listening on port %o", portsListen.http));
- if (process.env.KEY && process.env.CERT)
- node_https_1.default.createServer({ key: process.env.KEY, cert: process.env.CERT }, app).listen(portsListen.https, () => console.log("(HTTPS) Listening on port %o", portsListen.https));
-});
-// Print user request api
-app.use((req, _res, next) => {
- next();
- console.log("(%s %s): %s %s", req.protocol, req.ip, req.method, req.originalUrl);
-});
-// Global version
-const getAllLatest = () => Promise.all([
- (0, bedrock_1.getAll)().then(res => res.at(-1)),
- java_1.java.findOne({ latest: true }).lean(),
- pocketmine_1.pocketmine.findOne({ latest: true }).lean(),
- spigot_1.spigot.findOne({ latest: true }).lean(),
- paper_1.paper.findOne({ latest: true }).lean(),
- powernukkit_1.powernukkit.findOne({ latest: true }).lean(),
-]);
-app.get("/", (req, res) => getAllLatest().then(([bedrockVersions, javaVersions, pocketmineVersions, spigotVersions, paperVersions, powerNukkitVersions]) => {
- const data = {};
- const host = `${req.protocol}://${req.headers.host || "mcpeversions.sirherobrine23.org"}`;
- if (bedrockVersions)
- data["bedrock"] = { version: bedrockVersions.version, search: `${host}/bedrock/search?version=${bedrockVersions.version}` };
- if (javaVersions)
- data["java"] = { version: javaVersions.version, search: `${host}/java/search?version=${javaVersions.version}` };
- if (pocketmineVersions)
- data["pocketmine"] = { version: pocketmineVersions.version, search: `${host}/pocketmine/search?version=${pocketmineVersions.version}` };
- if (spigotVersions)
- data["spigot"] = { version: spigotVersions.version, search: `${host}/spigot/search?version=${spigotVersions.version}` };
- if (paperVersions)
- data["paper"] = { version: paperVersions.version, search: `${host}/paper/search?version=${paperVersions.version}` };
- if (powerNukkitVersions)
- data["powernukkit"] = { version: powerNukkitVersions.version, search: `${host}/powernukkit/search?version=${powerNukkitVersions.version}` };
- return res.json(data);
-}).catch(err => res.status(500).json({ message: "Sorry for error on our part", Error: String(err).replace("Error: ", "") })));
-// Routes
-app.use("/bedrock", bedrock_1.app);
-app.use("/java", java_1.app);
-app.use("/pocketmine", pocketmine_1.app);
-app.use("/spigot", spigot_1.app);
-app.use("/powernukkit", powernukkit_1.app);
-app.use("/paper", paper_1.app);
-//Return 404 for all other routes
-app.all("*", ({ res }) => res.status(404).json({ error: "Not found" }));
diff --git a/src/bin.d.ts b/src/bin.d.ts
deleted file mode 100644
index b798801..0000000
--- a/src/bin.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/usr/bin/env node
-export {};
diff --git a/src/bin.js b/src/bin.js
deleted file mode 100644
index 2f46ac3..0000000
--- a/src/bin.js
+++ /dev/null
@@ -1,188 +0,0 @@
-#!/usr/bin/env node
-"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const yargs_1 = __importDefault(require("yargs"));
-const index_1 = require("./index");
-function prettyDate(date) {
- const day = date.getDay();
- const month = date.getMonth() + 1;
- const Year = date.getFullYear();
- const hour = date.getHours();
- const minutes = date.getMinutes();
- return `${day > 9 ? day : "0" + day}/${month > 9 ? month : "0" + month}/${Year} ${hour > 9 ? hour : "0" + hour}:${minutes > 9 ? minutes : "0" + minutes}`;
-}
-function stringReplace(messeage, ...args) {
- const mat = ([...messeage.matchAll(/(%[a-z])/g)]);
- for (const matIndex in mat) {
- const [, text] = mat[matIndex];
- messeage = messeage.replace(text, args[matIndex]);
- }
- return messeage;
-}
-(0, yargs_1.default)(process.argv.slice(2)).help().version(false).alias("h", "help").wrap(yargs_1.default.terminalWidth()).command("bedrock", "Bedrock Platform", yarg => yarg.option("version", { alias: "v" }), async (options) => {
- if (options.version && typeof options.version === "string") {
- const data = await index_1.platformManeger.bedrock.find(options.version);
- console.log("Version: %s\n\trelease date: %s\n\tUrl: %s", data.version, prettyDate(data.date), data.url[process.platform] || "Current Platform not Avaible");
- }
- else {
- let consolePrint = "";
- if (Array.isArray(options.version)) {
- for (const version of options.version) {
- const data = await index_1.platformManeger.bedrock.find(version).catch(() => null);
- if (!data)
- continue;
- consolePrint += stringReplace("Version: %s\n\trelease date: %s\n\tUrl: %s\n", data.version, prettyDate(data.date), data.url[process.platform][process.arch] || "Current Platform not Avaible");
- }
- }
- else {
- for (const version of await index_1.platformManeger.bedrock.all()) {
- consolePrint += stringReplace("Version: %s\n\trelease date: %s\n\tUrl: %s\n", version.version, prettyDate(version.date), version.url[process.platform][process.arch] || "Current Platform not Avaible");
- }
- }
- if (!consolePrint.trim()) {
- console.log("No Versions to print!");
- process.exitCode = 1;
- return;
- }
- console.log(consolePrint.trim());
- }
-}).command("powernukkit", "powernukkit Platform", yarg => yarg.option("version", { alias: "v" }), async (options) => {
- if (options.version && typeof options.version === "string") {
- const data = await index_1.platformManeger.powernukkit.find(options.version);
- console.log("Version: %s, Minecraft version: %s\n\trelease date: %s\n\tUrl: %s\n", data.version, data.mcpeVersion, prettyDate(data.date), data.url);
- }
- else {
- let consolePrint = "";
- if (Array.isArray(options.version)) {
- for (const version of options.version) {
- const data = await index_1.platformManeger.powernukkit.find(version).catch(() => null);
- if (!data)
- continue;
- consolePrint += stringReplace("Version: %s, Minecraft version: %s\n\trelease date: %s\n\tUrl: %s\n", data.version, data.mcpeVersion, prettyDate(data.date), data.url);
- }
- }
- else {
- for (const version of await index_1.platformManeger.powernukkit.all()) {
- consolePrint += stringReplace("Version: %s, Minecraft version: %s\n\trelease date: %s\n\tUrl: %s\n", version.version, version.mcpeVersion, prettyDate(version.date), version.url);
- }
- }
- if (!consolePrint.trim()) {
- console.log("No Versions to print!");
- process.exitCode = 1;
- return;
- }
- console.log(consolePrint.trim());
- }
-}).command("pocketmine", "pocketmine Platform", yarg => yarg.option("version", { alias: "v" }), async (options) => {
- if (options.version && typeof options.version === "string") {
- const data = await index_1.platformManeger.pocketmine.find(options.version);
- console.log("Version: %s\n\trelease date: %s\n\tUrl: %s\n", data.version, prettyDate(data.date), data.url);
- }
- else {
- let consolePrint = "";
- if (Array.isArray(options.version)) {
- for (const version of options.version) {
- const data = await index_1.platformManeger.pocketmine.find(version).catch(() => null);
- if (!data)
- continue;
- consolePrint += stringReplace("Version: %s\n\trelease date: %s\n\tUrl: %s\n", data.version, prettyDate(data.date), data.url);
- }
- }
- else {
- for (const data of await index_1.platformManeger.pocketmine.all()) {
- consolePrint += stringReplace("Version: %s\n\trelease date: %s\n\tUrl: %s\n", data.version, prettyDate(data.date), data.url);
- }
- }
- if (!consolePrint.trim()) {
- console.log("No Versions to print!");
- process.exitCode = 1;
- return;
- }
- console.log(consolePrint.trim());
- }
-}).command("java", "Java Platform", yarg => yarg.option("version", { alias: "v" }), async (options) => {
- if (options.version && typeof options.version === "string") {
- const data = await index_1.platformManeger.java.find(options.version);
- console.log("Version: %s\n\trelease date: %s\n\tUrl: %s", data.version, prettyDate(data.date), data.url);
- }
- else {
- let consolePrint = "";
- if (Array.isArray(options.version)) {
- for (const version of options.version) {
- const data = await index_1.platformManeger.java.find(version).catch(() => null);
- if (!data)
- continue;
- consolePrint += stringReplace("Version: %s\n\trelease date: %s\n\tUrl: %s\n", data.version, prettyDate(data.date), data.url);
- }
- }
- else {
- for (const version of await index_1.platformManeger.java.all()) {
- consolePrint += stringReplace("Version: %s\n\trelease date: %s\n\tUrl: %s\n", version.version, prettyDate(version.date), version.url);
- }
- }
- if (!consolePrint.trim()) {
- console.log("No Versions to print!");
- process.exitCode = 1;
- return;
- }
- console.log(consolePrint.trim());
- }
-}).command("spigot", "spigot Platform", yarg => yarg.option("version", { alias: "v" }), async (options) => {
- if (options.version && typeof options.version === "string") {
- const data = await index_1.platformManeger.spigot.find(options.version);
- console.log("Version: %s\n\trelease date: %s\n\tUrl: %s", data.version, prettyDate(data.date), data.url);
- }
- else {
- let consolePrint = "";
- if (Array.isArray(options.version)) {
- for (const version of options.version) {
- const data = await index_1.platformManeger.spigot.find(version).catch(() => null);
- if (!data)
- continue;
- consolePrint += stringReplace("Version: %s\n\trelease date: %s\n\tUrl: %s\n", data.version, prettyDate(data.date), data.url);
- }
- }
- else {
- for (const version of await index_1.platformManeger.spigot.all()) {
- consolePrint += stringReplace("Version: %s\n\trelease date: %s\n\tUrl: %s\n", version.version, prettyDate(version.date), version.url);
- }
- }
- if (!consolePrint.trim()) {
- console.log("No Versions to print!");
- process.exitCode = 1;
- return;
- }
- console.log(consolePrint.trim());
- }
-}).command("paper", "paper Platform", yarg => yarg.option("version", { alias: "v" }), async (options) => {
- if (options.version && typeof options.version === "string") {
- const data = await index_1.platformManeger.paper.find(options.version);
- console.log("Version: %s\n\trelease date: %s\n\tUrl: %s", data.version, prettyDate(data.date), data.url);
- }
- else {
- let consolePrint = "";
- if (Array.isArray(options.version)) {
- for (const version of options.version) {
- const data = await index_1.platformManeger.paper.find(version).catch(() => null);
- if (!data)
- continue;
- consolePrint += stringReplace("Version: %s\n\trelease date: %s\n\tUrl: %s\n", data.version, prettyDate(data.date), data.url);
- }
- }
- else {
- for (const version of await index_1.platformManeger.paper.all()) {
- consolePrint += stringReplace("Version: %s\n\trelease date: %s\n\tUrl: %s\n", version.version, prettyDate(version.date), version.url);
- }
- }
- if (!consolePrint.trim()) {
- console.log("No Versions to print!");
- process.exitCode = 1;
- return;
- }
- console.log(consolePrint.trim());
- }
-})
- .parseAsync();
diff --git a/src/db/bedrock.d.ts b/src/db/bedrock.d.ts
deleted file mode 100644
index 418cfb0..0000000
--- a/src/db/bedrock.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-///
-export declare const app: import("express-serve-static-core").Router;
-export declare type bedrockSchema = {
- version: string;
- date: Date;
- url: {
- [platform in NodeJS.Platform]?: {
- [arch in NodeJS.Architecture]?: string;
- };
- };
-};
-export declare function getAll(): Promise;
diff --git a/src/db/bedrock.js b/src/db/bedrock.js
deleted file mode 100644
index c0b44de..0000000
--- a/src/db/bedrock.js
+++ /dev/null
@@ -1,21 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.getAll = exports.app = void 0;
-const core_utils_1 = require("@the-bds-maneger/core-utils");
-const express_1 = require("express");
-exports.app = (0, express_1.Router)();
-async function getAll() {
- return core_utils_1.httpRequest.getJSON("https://the-bds-maneger.github.io/BedrockFetch/all.json");
-}
-exports.getAll = getAll;
-exports.app.get("/", ({ res }) => getAll().then(data => res.json(data)));
-exports.app.get("/latest", async ({ res }) => res.json((await getAll()).at(-1)));
-exports.app.get("/search", async (req, res) => {
- let version = req.query.version;
- if (!version)
- return res.status(400).json({ error: "No version specified" });
- const versionFinded = (await getAll()).find(rel => rel.version === version);
- if (!versionFinded)
- return res.status(404).json({ error: "Version not found" });
- return res.json(versionFinded);
-});
diff --git a/src/db/connect.d.ts b/src/db/connect.d.ts
deleted file mode 100644
index fc7272a..0000000
--- a/src/db/connect.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import mongoose from "mongoose";
-export declare let authUsername: string;
-export declare let authPassword: string;
-export declare const mongoURL: string;
-export declare const connection: mongoose.Connection;
-export default connection;
diff --git a/src/db/connect.js b/src/db/connect.js
deleted file mode 100644
index 102e5e2..0000000
--- a/src/db/connect.js
+++ /dev/null
@@ -1,13 +0,0 @@
-"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.connection = exports.mongoURL = exports.authPassword = exports.authUsername = void 0;
-const mongoose_1 = __importDefault(require("mongoose"));
-exports.authUsername = (!!process.env.MONGO_USER) ? process.env.MONGO_USER : "public";
-exports.authPassword = (!!process.env.MONGO_PASSWORD) ? process.env.MONGO_PASSWORD : "n0v8IBKEI920sfy8";
-exports.mongoURL = process.env.BDSVERSIONDB || `mongodb+srv://${exports.authUsername}:${exports.authPassword}@versionstorage.qgh8v.mongodb.net/v2_versions`;
-// Connect to MongoDB
-exports.connection = mongoose_1.default.createConnection(exports.mongoURL);
-exports.default = exports.connection;
diff --git a/src/db/java.d.ts b/src/db/java.d.ts
deleted file mode 100644
index 0995c76..0000000
--- a/src/db/java.d.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import mongoose from "mongoose";
-export declare const app: import("express-serve-static-core").Router;
-export declare type javaSchema = {
- version: string;
- date: Date;
- latest: boolean;
- url: string;
-};
-export declare const java: mongoose.Model;
-export default java;
diff --git a/src/db/java.js b/src/db/java.js
deleted file mode 100644
index 827ef7b..0000000
--- a/src/db/java.js
+++ /dev/null
@@ -1,32 +0,0 @@
-"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.java = exports.app = void 0;
-const mongoose_1 = __importDefault(require("mongoose"));
-const connect_1 = __importDefault(require("./connect"));
-const express_1 = require("express");
-exports.app = (0, express_1.Router)();
-exports.java = connect_1.default.model("java", new mongoose_1.default.Schema({
- version: {
- type: String,
- required: true,
- unique: true
- },
- date: Date,
- latest: Boolean,
- url: String
-}));
-exports.default = exports.java;
-exports.app.get("/", ({ res }) => exports.java.find().lean().then(data => res.json(data)));
-exports.app.get("/latest", async ({ res }) => res.json(await exports.java.findOne({ latest: true }).lean()));
-exports.app.get("/search", async (req, res) => {
- let version = req.query.version;
- if (!version)
- return res.status(400).json({ error: "No version specified" });
- const versionFinded = await exports.java.findOne({ version: version }).lean();
- if (!versionFinded)
- return res.status(404).json({ error: "Version not found" });
- return res.json(versionFinded);
-});
diff --git a/src/db/paper.d.ts b/src/db/paper.d.ts
deleted file mode 100644
index 5e62245..0000000
--- a/src/db/paper.d.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import mongoose from "mongoose";
-export declare const app: import("express-serve-static-core").Router;
-export declare type paperSchema = {
- version: string;
- build: number;
- date: Date;
- latest: boolean;
- url: string;
-};
-export declare const paper: mongoose.Model;
diff --git a/src/db/paper.js b/src/db/paper.js
deleted file mode 100644
index c3562b9..0000000
--- a/src/db/paper.js
+++ /dev/null
@@ -1,42 +0,0 @@
-"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.paper = exports.app = void 0;
-const mongoose_1 = __importDefault(require("mongoose"));
-const connect_1 = __importDefault(require("./connect"));
-const express_1 = require("express");
-exports.app = (0, express_1.Router)();
-exports.paper = connect_1.default.model("paper", new mongoose_1.default.Schema({
- version: String,
- build: Number,
- date: Date,
- latest: Boolean,
- url: String
-}));
-exports.app.get("/", ({ res }) => exports.paper.find().lean().then(data => res.json(data)));
-exports.app.get("/latest", ({ res }) => exports.paper.findOne({ latest: true }).lean().then(data => res.json(data)));
-exports.app.get("/search", async (req, res) => {
- let version = req.query.version;
- if (!version)
- return res.status(400).json({ erro: "Not allowd blank version" });
- let build = parseInt(req.query.build);
- if (isNaN(build))
- build = undefined;
- if (!!build) {
- const info = await exports.paper.findOne({
- version,
- build
- });
- if (!info)
- return res.status(400).json({ error: "version and build not exists" });
- return res.json(info);
- }
- const info = await exports.paper.findOne({
- version
- });
- if (!info)
- return res.status(400).json({ error: "version not exists" });
- return res.json(info);
-});
diff --git a/src/db/pocketmine.d.ts b/src/db/pocketmine.d.ts
deleted file mode 100644
index 5042233..0000000
--- a/src/db/pocketmine.d.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import mongoose from "mongoose";
-export declare const app: import("express-serve-static-core").Router;
-export declare type pocketminemmpSchema = {
- version: string;
- date: Date;
- latest: boolean;
- url: string;
-};
-export declare const pocketmine: mongoose.Model;
diff --git a/src/db/pocketmine.js b/src/db/pocketmine.js
deleted file mode 100644
index f8765b9..0000000
--- a/src/db/pocketmine.js
+++ /dev/null
@@ -1,54 +0,0 @@
-"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.pocketmine = exports.app = void 0;
-const mongoose_1 = __importDefault(require("mongoose"));
-const connect_1 = __importDefault(require("./connect"));
-const express_1 = require("express");
-const core_utils_1 = require("@the-bds-maneger/core-utils");
-exports.app = (0, express_1.Router)();
-exports.pocketmine = connect_1.default.model("pocketminemmp", new mongoose_1.default.Schema({
- version: {
- type: String,
- required: true,
- unique: true
- },
- date: Date,
- latest: Boolean,
- url: String
-}));
-exports.app.get("/", ({ res }) => exports.pocketmine.find().lean().then(data => res.json(data)));
-exports.app.get("/latest", async ({ res }) => res.json(await exports.pocketmine.findOne({ latest: true }).lean()));
-exports.app.get("/bin", async (req, res) => {
- let os = RegExp(req.query.os || "(win32|windows|linux|macos|mac)");
- let arch = RegExp(req.query.arch || ".*");
- const redirect = req.query.redirect === "true";
- const rele = await core_utils_1.httpRequestGithub.GithubRelease("The-Bds-Maneger/Build-PHP-Bins");
- const Files = [];
- for (const release of rele) {
- for (const asset of release.assets) {
- if (os.test(asset.name) && arch.test(asset.name))
- Files.push({
- url: asset.browser_download_url,
- name: asset.name
- });
- }
- }
- if (Files.length >= 1) {
- if (redirect)
- return res.redirect(Files[0].url);
- return res.json(Files);
- }
- return res.status(404).json({ error: "No bin found" });
-});
-exports.app.get("/search", async (req, res) => {
- let version = req.query.version;
- if (!version)
- return res.status(400).json({ error: "No version specified" });
- const versionFinded = await exports.pocketmine.findOne({ version }).lean();
- if (!versionFinded)
- return res.status(404).json({ error: "Version not found" });
- return res.json(versionFinded);
-});
diff --git a/src/db/powernukkit.d.ts b/src/db/powernukkit.d.ts
deleted file mode 100644
index 1088686..0000000
--- a/src/db/powernukkit.d.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-import mongoose from "mongoose";
-export declare const app: import("express-serve-static-core").Router;
-export declare type powernukkitSchema = {
- version: string;
- mcpeVersion: string;
- date: Date;
- latest: boolean;
- url: string;
- variantType: "stable" | "snapshot";
-};
-export declare const powernukkit: mongoose.Model;
diff --git a/src/db/powernukkit.js b/src/db/powernukkit.js
deleted file mode 100644
index 09e57a3..0000000
--- a/src/db/powernukkit.js
+++ /dev/null
@@ -1,34 +0,0 @@
-"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.powernukkit = exports.app = void 0;
-const mongoose_1 = __importDefault(require("mongoose"));
-const connect_1 = __importDefault(require("./connect"));
-const express_1 = require("express");
-exports.app = (0, express_1.Router)();
-exports.powernukkit = connect_1.default.model("powernukkit", new mongoose_1.default.Schema({
- version: {
- type: String,
- unique: false,
- required: true
- },
- mcpeVersion: String,
- date: Date,
- url: String,
- variantType: String,
- latest: Boolean
-}));
-exports.app.get("/", ({ res }) => exports.powernukkit.find().lean().then(data => res.json(data)));
-exports.app.get("/latest", ({ res }) => exports.powernukkit.findOne({ latest: true }).lean().then(data => res.json(data)));
-exports.app.get("/search", async (req, res) => {
- let version = req.query.version;
- let variant = req.query.variant || undefined;
- if (!version)
- return res.status(400).json({ error: "No version specified" });
- const versionDB = await exports.powernukkit.findOne({ version, variant: { to: variant } }).lean();
- if (!versionDB)
- return res.status(404).json({ error: "Version not found" });
- return res.json(versionDB);
-});
diff --git a/src/db/spigot.d.ts b/src/db/spigot.d.ts
deleted file mode 100644
index cb6ffcb..0000000
--- a/src/db/spigot.d.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import mongoose from "mongoose";
-export declare const app: import("express-serve-static-core").Router;
-export declare type spigotSchema = {
- version: string;
- date: Date;
- latest: boolean;
- url: string;
-};
-export declare const spigot: mongoose.Model;
diff --git a/src/db/spigot.js b/src/db/spigot.js
deleted file mode 100644
index 6d42fac..0000000
--- a/src/db/spigot.js
+++ /dev/null
@@ -1,31 +0,0 @@
-"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.spigot = exports.app = void 0;
-const mongoose_1 = __importDefault(require("mongoose"));
-const connect_1 = __importDefault(require("./connect"));
-const express_1 = require("express");
-exports.app = (0, express_1.Router)();
-exports.spigot = connect_1.default.model("spigot", new mongoose_1.default.Schema({
- version: {
- type: String,
- required: true,
- unique: true
- },
- date: Date,
- latest: Boolean,
- url: String
-}));
-exports.app.get("/", ({ res }) => exports.spigot.find().lean().then(data => res.json(data)));
-exports.app.get("/latest", async ({ res }) => res.json(await exports.spigot.findOne({ latest: true }).lean()));
-exports.app.get("/search", async (req, res) => {
- let version = req.query.version;
- if (!version)
- return res.status(400).json({ error: "No version specified" });
- const versionFinded = await exports.spigot.findOne({ version }).lean();
- if (!versionFinded)
- return res.status(404).json({ error: "Version not found" });
- return res.json(versionFinded);
-});
diff --git a/src/exports.d.ts b/src/exports.d.ts
deleted file mode 100644
index cb0ff5c..0000000
--- a/src/exports.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export {};
diff --git a/src/exports.js b/src/exports.js
deleted file mode 100644
index be1c5ee..0000000
--- a/src/exports.js
+++ /dev/null
@@ -1,80 +0,0 @@
-"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const node_fs_1 = __importDefault(require("node:fs"));
-const node_path_1 = __importDefault(require("node:path"));
-const promises_1 = __importDefault(require("node:fs/promises"));
-const index_1 = require("./index");
-const rootVersions = node_path_1.default.join(process.cwd(), "versions");
-const Bedrock = node_path_1.default.join(rootVersions, "bedrock");
-const Pocketmine = node_path_1.default.join(rootVersions, "pocketmine");
-const Powernukkit = node_path_1.default.join(rootVersions, "powernukkit");
-const Java = node_path_1.default.join(rootVersions, "java");
-const Spigot = node_path_1.default.join(rootVersions, "spigot");
-const Paper = node_path_1.default.join(rootVersions, "paper");
-(async function () {
- if (!node_fs_1.default.existsSync(rootVersions))
- await promises_1.default.mkdir(rootVersions, { recursive: true });
- if (!node_fs_1.default.existsSync(Bedrock))
- await promises_1.default.mkdir(Bedrock, { recursive: true });
- if (!node_fs_1.default.existsSync(Pocketmine))
- await promises_1.default.mkdir(Pocketmine, { recursive: true });
- if (!node_fs_1.default.existsSync(Powernukkit))
- await promises_1.default.mkdir(Powernukkit, { recursive: true });
- if (!node_fs_1.default.existsSync(Java))
- await promises_1.default.mkdir(Java, { recursive: true });
- if (!node_fs_1.default.existsSync(Spigot))
- await promises_1.default.mkdir(Spigot, { recursive: true });
- if (!node_fs_1.default.existsSync(Paper))
- await promises_1.default.mkdir(Paper, { recursive: true });
- const bedrockData = await (0, index_1.findVersion)("bedrock", "all", true);
- promises_1.default.writeFile(node_path_1.default.join(Bedrock, "latest.json"), JSON.stringify(bedrockData.at(-1), null, 2));
- promises_1.default.writeFile(node_path_1.default.join(Bedrock, "all.json"), JSON.stringify(bedrockData, null, 2));
- await Promise.all(bedrockData.map(async (releases) => {
- const version = node_path_1.default.join(Bedrock, `${releases.version}.json`);
- await promises_1.default.writeFile(version, JSON.stringify(releases, null, 2));
- await promises_1.default.utimes(version, new Date(releases.date), new Date(releases.date));
- }));
- const PocketmineData = await (0, index_1.findVersion)("pocketmine", "all", true);
- promises_1.default.writeFile(node_path_1.default.join(Pocketmine, "latest.json"), JSON.stringify(PocketmineData.find(release => release.latest), null, 2));
- promises_1.default.writeFile(node_path_1.default.join(Pocketmine, "all.json"), JSON.stringify(PocketmineData, null, 2));
- await Promise.all(PocketmineData.map(async (releases) => {
- const version = node_path_1.default.join(Pocketmine, `${releases.version}.json`);
- await promises_1.default.writeFile(version, JSON.stringify(releases, null, 2));
- await promises_1.default.utimes(version, new Date(releases.date), new Date(releases.date));
- }));
- const PowernukkitData = await (0, index_1.findVersion)("powernukkit", "all", true);
- promises_1.default.writeFile(node_path_1.default.join(Powernukkit, "latest.json"), JSON.stringify(PowernukkitData.find(release => release.latest), null, 2));
- promises_1.default.writeFile(node_path_1.default.join(Powernukkit, "all.json"), JSON.stringify(PowernukkitData, null, 2));
- await Promise.all(PowernukkitData.map(async (releases) => {
- const version = node_path_1.default.join(Powernukkit, `${releases.version}.json`);
- await promises_1.default.writeFile(version, JSON.stringify(releases, null, 2));
- await promises_1.default.utimes(version, new Date(releases.date), new Date(releases.date));
- }));
- const JavaData = await (0, index_1.findVersion)("java", "all", true);
- promises_1.default.writeFile(node_path_1.default.join(Java, "latest.json"), JSON.stringify(JavaData.find(release => release.latest), null, 2));
- promises_1.default.writeFile(node_path_1.default.join(Java, "all.json"), JSON.stringify(JavaData, null, 2));
- await Promise.all(JavaData.map(async (releases) => {
- const version = node_path_1.default.join(Java, `${releases.version}.json`);
- await promises_1.default.writeFile(version, JSON.stringify(releases, null, 2));
- await promises_1.default.utimes(version, new Date(releases.date), new Date(releases.date));
- }));
- const SpigotData = await (0, index_1.findVersion)("spigot", "all", true);
- promises_1.default.writeFile(node_path_1.default.join(Spigot, "latest.json"), JSON.stringify(SpigotData.find(release => release.latest), null, 2));
- promises_1.default.writeFile(node_path_1.default.join(Spigot, "all.json"), JSON.stringify(SpigotData, null, 2));
- await Promise.all(SpigotData.map(async (releases) => {
- const version = node_path_1.default.join(Spigot, `${releases.version}.json`);
- await promises_1.default.writeFile(version, JSON.stringify(releases, null, 2));
- await promises_1.default.utimes(version, new Date(releases.date), new Date(releases.date));
- }));
- const PaperData = await (0, index_1.findVersion)("paper", "all", true);
- promises_1.default.writeFile(node_path_1.default.join(Paper, "latest.json"), JSON.stringify(PaperData.find(release => release.latest), null, 2));
- promises_1.default.writeFile(node_path_1.default.join(Paper, "all.json"), JSON.stringify(PaperData, null, 2));
- await Promise.all(PaperData.map(async (releases) => {
- const version = node_path_1.default.join(Paper, `${releases.version}_${releases.build}.json`);
- await promises_1.default.writeFile(version, JSON.stringify(releases, null, 2));
- await promises_1.default.utimes(version, new Date(releases.date), new Date(releases.date));
- }));
-})();
diff --git a/src/fetchVersion/Java.d.ts b/src/fetchVersion/Java.d.ts
deleted file mode 100644
index fa26664..0000000
--- a/src/fetchVersion/Java.d.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-export default function UpdateDatabase(): Promise<{
- new: import("mongoose").LeanDocument;
- old: import("mongoose").LeanDocument;
-}>;
diff --git a/src/fetchVersion/Java.js b/src/fetchVersion/Java.js
deleted file mode 100644
index 20338bf..0000000
--- a/src/fetchVersion/Java.js
+++ /dev/null
@@ -1,32 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-const core_utils_1 = require("@the-bds-maneger/core-utils");
-const java_1 = require("../db/java");
-async function Add(Version, versionDate, url) {
- if (await java_1.java.findOne({ version: Version }).lean().then(data => !!data).catch(() => true))
- return;
- await java_1.java.create({
- version: Version,
- date: versionDate,
- latest: false,
- url: url
- });
-}
-async function Find() {
- var _a, _b, _c, _d;
- const Versions = await core_utils_1.httpRequest.getJSON("https://launchermeta.mojang.com/mc/game/version_manifest_v2.json");
- for (const ver of Versions.versions.filter(a => a.type === "release")) {
- const Release = await core_utils_1.httpRequest.getJSON(ver.url);
- if (!!((_b = (_a = Release === null || Release === void 0 ? void 0 : Release.downloads) === null || _a === void 0 ? void 0 : _a.server) === null || _b === void 0 ? void 0 : _b.url))
- await Add(ver.id, new Date(ver.releaseTime), (_d = (_c = Release === null || Release === void 0 ? void 0 : Release.downloads) === null || _c === void 0 ? void 0 : _c.server) === null || _d === void 0 ? void 0 : _d.url);
- }
- return await java_1.java.findOneAndUpdate({ version: Versions.latest.release }, { $set: { latest: true } }).lean();
-}
-async function UpdateDatabase() {
- const latestVersion = await java_1.java.findOneAndUpdate({ latest: true }, { $set: { latest: false } }).lean();
- return {
- new: await Find(),
- old: latestVersion
- };
-}
-exports.default = UpdateDatabase;
diff --git a/src/fetchVersion/Paper.d.ts b/src/fetchVersion/Paper.d.ts
deleted file mode 100644
index 1b5e9f8..0000000
--- a/src/fetchVersion/Paper.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-export default function find(): Promise;
diff --git a/src/fetchVersion/Paper.js b/src/fetchVersion/Paper.js
deleted file mode 100644
index e1c6409..0000000
--- a/src/fetchVersion/Paper.js
+++ /dev/null
@@ -1,27 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-const core_utils_1 = require("@the-bds-maneger/core-utils");
-const paper_1 = require("../db/paper");
-async function find() {
- const versions = (await core_utils_1.httpRequest.getJSON("https://api.papermc.io/v2/projects/paper")).versions;
- for (const version of versions) {
- const builds = await core_utils_1.httpRequest.getJSON(`https://api.papermc.io/v2/projects/paper/versions/${version}/builds`);
- await Promise.all(builds.builds.map(async function (build) {
- const downloadUrl = `https://api.papermc.io/v2/projects/paper/versions/${builds.version}/builds/${build.build}/downloads/${build.downloads.application.name}`;
- if (await paper_1.paper.findOne({ url: downloadUrl }).lean())
- return;
- await paper_1.paper.create({
- version: builds.version,
- build: build.build,
- date: new Date(build.time),
- url: downloadUrl,
- latest: false
- });
- return;
- }));
- }
- await paper_1.paper.findOneAndUpdate({ latest: true }, { $set: { latest: false } }).lean();
- const latestVersionByDate = (await paper_1.paper.find().lean()).sort((a, b) => b.date.getTime() - a.date.getTime())[0];
- await paper_1.paper.findByIdAndUpdate(latestVersionByDate._id, { $set: { latest: true } }).lean();
-}
-exports.default = find;
diff --git a/src/fetchVersion/Pocketmine.d.ts b/src/fetchVersion/Pocketmine.d.ts
deleted file mode 100644
index bbd4c9a..0000000
--- a/src/fetchVersion/Pocketmine.d.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-///
-export default function UpdateDatabase(): Promise<{
- new: import("mongoose").LeanDocument;
- old: import("mongoose").LeanDocument;
-}>;
diff --git a/src/fetchVersion/Pocketmine.js b/src/fetchVersion/Pocketmine.js
deleted file mode 100644
index 8591df5..0000000
--- a/src/fetchVersion/Pocketmine.js
+++ /dev/null
@@ -1,38 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-const core_utils_1 = require("@the-bds-maneger/core-utils");
-const pocketmine_1 = require("../db/pocketmine");
-async function Add(Version, versionDate, url) {
- if (await pocketmine_1.pocketmine.findOne({ version: Version }).lean().then(data => !!data).catch(() => true))
- return;
- await pocketmine_1.pocketmine.create({
- version: Version,
- date: versionDate,
- latest: false,
- url: url
- });
-}
-async function Find() {
- return await Promise.all((await core_utils_1.httpRequestGithub.GithubRelease("pmmp/PocketMine-MP")).filter(Release => !/beta|alpha/gi.test(Release.tag_name.toLowerCase())).map(Release => {
- Release.assets = Release.assets.filter(asset => asset.name.endsWith(".phar"));
- return Release;
- }).filter(a => a.assets.length > 0).map(release => {
- return Add(release.tag_name, new Date(release.published_at), release.assets[0].browser_download_url).catch(err => {
- console.log("Pocketmine PMMP: Version %s, Error: %o", release.tag_name, err);
- }).then(() => ({
- Date: new Date(release.published_at),
- Version: release.tag_name,
- url: release.assets[0].browser_download_url
- }));
- }));
-}
-async function UpdateDatabase() {
- const latestVersion = await pocketmine_1.pocketmine.findOneAndUpdate({ latest: true }, { $set: { latest: false } }).lean();
- const Releases = await Find();
- const newLatest = await pocketmine_1.pocketmine.findOneAndUpdate({ version: Releases[0].Version }, { $set: { latest: true } }).lean();
- return {
- new: newLatest,
- old: latestVersion
- };
-}
-exports.default = UpdateDatabase;
diff --git a/src/fetchVersion/Powernukkit.d.ts b/src/fetchVersion/Powernukkit.d.ts
deleted file mode 100644
index d445ac8..0000000
--- a/src/fetchVersion/Powernukkit.d.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-export declare const exportUrl = "https://raw.githubusercontent.com/PowerNukkit/powernukkit-version-aggregator/master/powernukkit-versions.json";
-export declare type Release = {
- version: string;
- releaseTime: number;
- minecraftVersion: string;
- artefacts: string[];
- commitId: string;
- snapshotBuild?: number;
-};
-export declare type PowernukkitVersions = {
- releases: Release[];
- snapshots: Release[];
-};
-export default function find(): Promise;
diff --git a/src/fetchVersion/Powernukkit.js b/src/fetchVersion/Powernukkit.js
deleted file mode 100644
index cab3760..0000000
--- a/src/fetchVersion/Powernukkit.js
+++ /dev/null
@@ -1,163 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.exportUrl = void 0;
-const powernukkit_1 = require("../db/powernukkit");
-const core_utils_1 = require("@the-bds-maneger/core-utils");
-exports.exportUrl = "https://raw.githubusercontent.com/PowerNukkit/powernukkit-version-aggregator/master/powernukkit-versions.json";
-function buildVersion(data) {
- let artefacts = {};
- data.artefacts.forEach(function (artefactId) {
- artefacts[artefactId] = buildArtefactUrl(data, artefactId);
- });
- if (data.commitId) {
- artefacts["GIT_SOURCE"] = buildArtefactUrl(data, "GIT_SOURCE");
- }
- if (!data.snapshotBuild) {
- artefacts["ONLINE_DOC"] = buildArtefactUrl(data, "ONLINE_DOC");
- }
- const releaseTime = new Date(data.releaseTime);
- let url = getBestDownloadUrl(artefacts);
- if (!url)
- return;
- const schema = {
- version: data.version,
- mcpeVersion: data.minecraftVersion,
- date: releaseTime,
- latest: false,
- variantType: data.snapshotBuild === undefined ? "stable" : "snapshot",
- url
- };
- return schema;
-}
-function getBestDownloadUrl(artefacts) {
- if (artefacts.SHADED_JAR) {
- return artefacts.SHADED_JAR;
- }
- else {
- return artefacts.REDUCED_JAR;
- }
-}
-function buildArtefactUrl(data, artefactId) {
- if (artefactId == "GIT_SOURCE") {
- return buildGitSourceUrl(data);
- }
- else if (artefactId == "ONLINE_DOC") {
- return buildOnlineDocUrl(data);
- }
- else if (data.snapshotBuild) {
- return buildSnapshotArtefactUrl(data, artefactId);
- }
- else {
- return buildReleaseArtefactUrl(data, artefactId);
- }
-}
-function buildOnlineDocUrl(data) {
- if (data.snapshotBuild) {
- if (data.artefacts.includes("JAVADOC_JAR")) {
- return buildSnapshotArtefactUrl(data, "JAVADOC_JAR");
- }
- }
- return "https://devs.powernukkit.org/#javadoc";
-}
-function buildGitSourceUrl(data) {
- if (data.commitId) {
- return "https://github.com/PowerNukkit/PowerNukkit/tree/" + data.commitId;
- }
- else if (data.snapshotBuild) {
- if (data.artefacts.includes("SHADED_SOURCES_JAR")) {
- return buildSnapshotArtefactUrl(data, "SHADED_SOURCES_JAR");
- }
- else if (data.artefacts.includes("REDUCED_SOURCES_JAR")) {
- return buildSnapshotArtefactUrl(data, "REDUCED_SOURCES_JAR");
- }
- }
- else {
- if (data.artefacts.includes("SHADED_SOURCES_JAR")) {
- return buildReleaseArtefactUrl(data, "SHADED_SOURCES_JAR");
- }
- else if (data.artefacts.includes("REDUCED_SOURCES_JAR")) {
- return buildReleaseArtefactUrl(data, "REDUCED_SOURCES_JAR");
- }
- }
-}
-function buildReleaseArtefactUrl(data, artefactId) {
- if (!data.artefacts.includes(artefactId)) {
- return;
- }
- return "https://search.maven.org/remotecontent?filepath=org/powernukkit/powernukkit/" +
- data.version +
- "/powernukkit-" +
- data.version +
- getArtefactExtension(artefactId);
-}
-function buildSnapshotArtefactUrl(data, artefactId) {
- if (!data.artefacts.includes(artefactId)) {
- return;
- }
- let dt = new Date(data.releaseTime);
- let snapshotCode = dt.getUTCFullYear().toString().padStart(4, "0") +
- (dt.getUTCMonth() + 1).toString().padStart(2, "0") +
- dt.getUTCDate().toString().padStart(2, "0") +
- "." +
- dt.getUTCHours().toString().padStart(2, "0") +
- dt.getUTCMinutes().toString().padStart(2, "0") +
- dt.getUTCSeconds().toString().padStart(2, "0") +
- "-" +
- data.snapshotBuild;
- let snapshotIndex = data.version.indexOf("-SNAPSHOT");
- let version = data.version.substring(0, snapshotIndex);
- let extension = getArtefactExtension(artefactId);
- return "https://oss.sonatype.org/content/repositories/snapshots/org/powernukkit/powernukkit" +
- "/" +
- version + "-SNAPSHOT" +
- "/" +
- "powernukkit-" + version +
- "-" +
- snapshotCode +
- extension;
-}
-function getArtefactExtension(artefactId) {
- let extension = ".unknown";
- switch (artefactId) {
- case "REDUCED_JAR":
- extension = ".jar";
- break;
- case "REDUCED_SOURCES_JAR":
- extension = "-sources.jar";
- break;
- case "SHADED_JAR":
- extension = "-shaded.jar";
- break;
- case "SHADED_SOURCES_JAR":
- extension = "-shaded-sources.jar";
- break;
- case "JAVADOC_JAR":
- extension = "-javadoc.jar";
- break;
- }
- return extension;
-}
-async function find() {
- const releases_version = await core_utils_1.httpRequest.getJSON(exports.exportUrl);
- for (const stable of releases_version.releases) {
- const data = buildVersion(stable);
- if (!data)
- continue;
- if (await powernukkit_1.powernukkit.findOne({ version: data.version }).lean())
- continue;
- await powernukkit_1.powernukkit.create(data);
- }
- for (const snapshot of releases_version.snapshots) {
- const data = buildVersion(snapshot);
- if (!data)
- continue;
- if (await powernukkit_1.powernukkit.findOne({ version: data.version }).lean())
- continue;
- await powernukkit_1.powernukkit.create(data);
- }
- const oldLatest = await powernukkit_1.powernukkit.findOneAndUpdate({ latest: true }, { $set: { latest: false } }).lean();
- const latestVersion = (await powernukkit_1.powernukkit.find({ variantType: "stable" }).lean()).sort((b, a) => a.date.getTime() - b.date.getTime())[0];
- await powernukkit_1.powernukkit.findOneAndUpdate({ version: latestVersion.version, variant: { variantType: "stable" } }, { $set: { latest: true } }).lean().catch(err => powernukkit_1.powernukkit.findOneAndUpdate({ version: oldLatest.version }, { $set: { latest: true } }).lean().then(() => Promise.reject(err)));
- return;
-}
-exports.default = find;
diff --git a/src/fetchVersion/Spigot.d.ts b/src/fetchVersion/Spigot.d.ts
deleted file mode 100644
index fda5536..0000000
--- a/src/fetchVersion/Spigot.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export declare const urlRegex: RegExp;
-export default function UpdateDatabase(): Promise;
diff --git a/src/fetchVersion/Spigot.js b/src/fetchVersion/Spigot.js
deleted file mode 100644
index 5d4588b..0000000
--- a/src/fetchVersion/Spigot.js
+++ /dev/null
@@ -1,43 +0,0 @@
-"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.urlRegex = void 0;
-const jsdom_1 = __importDefault(require("jsdom"));
-const core_utils_1 = require("@the-bds-maneger/core-utils");
-const spigot_1 = require("../db/spigot");
-exports.urlRegex = /http[s]:\/\/.*/;
-async function Find() {
- const { document } = (new jsdom_1.default.JSDOM(await core_utils_1.httpRequest.bufferFetch("https://getbukkit.org/download/spigot").then(res => res.data.toString("utf8")).catch(err => { console.log(err); return ""; }))).window;
- const dooms = document.querySelectorAll("#download > div > div > div > div");
- const Versions = await Promise.all(([...dooms]).map(async (DOM) => {
- const download = (new jsdom_1.default.JSDOM(await core_utils_1.httpRequest.bufferFetch(DOM.querySelector("div > div.col-sm-4 > div.btn-group > a")["href"]).then(res => res.data.toString("utf8"))));
- const serverInfo = {
- version: String(DOM.querySelector("div:nth-child(1) > h2").textContent),
- Date: new Date(DOM.querySelector("div:nth-child(3) > h3").textContent),
- url: download.window.document.querySelector("#get-download > div > div > div:nth-child(2) > div > h2 > a")["href"]
- };
- if (!exports.urlRegex.test(serverInfo.url) || !serverInfo.url)
- return null;
- return serverInfo;
- }));
- for (const Version of Versions.filter(a => a)) {
- if (await spigot_1.spigot.findOne({ version: Version.version }).lean())
- continue;
- console.log("Spigot", Version.version, Version.url);
- await spigot_1.spigot.create({
- version: Version.version,
- date: Version.Date,
- latest: false,
- url: Version.url
- });
- }
- await spigot_1.spigot.findOneAndUpdate({ latest: true }, { $set: { latest: false } }).lean();
- const latestVersion = (await spigot_1.spigot.find().lean()).sort((b, a) => a.date.getTime() - b.date.getTime())[0];
- await spigot_1.spigot.findByIdAndUpdate(latestVersion._id, { $set: { latest: true } });
-}
-async function UpdateDatabase() {
- await Find();
-}
-exports.default = UpdateDatabase;
diff --git a/src/fetchVersion/index.d.ts b/src/fetchVersion/index.d.ts
deleted file mode 100644
index b798801..0000000
--- a/src/fetchVersion/index.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/usr/bin/env node
-export {};
diff --git a/src/fetchVersion/index.js b/src/fetchVersion/index.js
deleted file mode 100644
index bb96d65..0000000
--- a/src/fetchVersion/index.js
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/env node
-"use strict";
-var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const yargs_1 = __importDefault(require("yargs"));
-const Pocketmine_1 = __importDefault(require("./Pocketmine"));
-const Java_1 = __importDefault(require("./Java"));
-const Spigot_1 = __importDefault(require("./Spigot"));
-const Paper_1 = __importDefault(require("./Paper"));
-const Powernukkit_1 = __importDefault(require("./Powernukkit"));
-const options = (0, yargs_1.default)(process.argv.slice(2)).help().version(false).alias("h", "help").wrap(yargs_1.default.terminalWidth()).options("all", {
- description: "Fetch all plaftorms",
- type: "boolean"
-}).option("java", {
- description: "Fetch Java versions",
- type: "boolean"
-}).option("pocketmine", {
- description: "Fetch Pocketmine-MP versions",
- type: "boolean"
-}).option("spigot", {
- description: "Fetch Spigot versions",
- type: "boolean"
-}).option("paper", {
- description: "Fetch Paper versions",
- type: "boolean"
-}).option("powernukkit", {
- description: "Fetch Powernukkit versions",
- type: "boolean"
-})
- .parseSync();
-async function all() {
- await (0, Java_1.default)();
- await (0, Pocketmine_1.default)();
- await (0, Spigot_1.default)();
- await (0, Paper_1.default)();
- await (0, Powernukkit_1.default)();
-}
-if (options.java)
- (0, Java_1.default)().then(() => { console.log("Java sucess update"); process.exit(0); }).catch(err => { console.log("Java catch Error: %s", String(err)); process.exit(1); });
-else if (options.spigot)
- (0, Spigot_1.default)().then(() => { console.log("Spigot sucess update"); process.exit(0); }).catch(err => { console.log("Spigot catch Error: %s", String(err)); process.exit(1); });
-else if (options.pocketmine)
- (0, Pocketmine_1.default)().then(() => { console.log("Pocketmine sucess update"); process.exit(0); }).catch(err => { console.log("Pocketmine catch Error: %s", String(err)); process.exit(1); });
-else if (options.paper)
- (0, Paper_1.default)().then(() => { console.log("Paper sucess update"); process.exit(0); }).catch(err => { console.log("Paper catch Error: %s", String(err)); process.exit(1); });
-else if (options.powernukkit)
- (0, Powernukkit_1.default)().then(() => { console.log("Powernukkit sucess update"); process.exit(0); }).catch(err => { console.log("Powernukkit catch Error: %s", String(err)); process.exit(1); });
-else if (options.all)
- all().then(() => process.exit(0)).catch(err => { console.trace(err); process.exit(1); });
-else {
- console.log("No options set");
- process.exit(1);
-}
diff --git a/src/fetchVersion/types/Java.d.ts b/src/fetchVersion/types/Java.d.ts
deleted file mode 100644
index e62624f..0000000
--- a/src/fetchVersion/types/Java.d.ts
+++ /dev/null
@@ -1,165 +0,0 @@
-export declare type javaRelease = {
- arguments: {
- game: Array;
- jvm: [
- {
- rules: Array<{
- action: string;
- os: {
- name: string;
- };
- }>;
- value: Array;
- },
- {
- rules: Array<{
- action: string;
- os: {
- name: string;
- };
- }>;
- value: string;
- },
- {
- rules: Array<{
- action: string;
- os: {
- name: string;
- version: string;
- };
- }>;
- value: Array;
- },
- {
- rules: Array<{
- action: string;
- os: {
- arch: string;
- };
- }>;
- value: string;
- },
- string,
- string,
- string,
- string,
- string
- ];
- };
- assetIndex: {
- id: string;
- sha1: string;
- size: number;
- totalSize: number;
- url: string;
- };
- assets: string;
- complianceLevel: number;
- downloads: {
- client: {
- sha1: string;
- size: number;
- url: string;
- };
- client_mappings: {
- sha1: string;
- size: number;
- url: string;
- };
- server: {
- sha1: string;
- size: number;
- url: string;
- };
- server_mappings: {
- sha1: string;
- size: number;
- url: string;
- };
- };
- id: string;
- javaVersion: {
- component: string;
- majorVersion: number;
- };
- libraries: Array<{
- downloads: {
- artifact: {
- path: string;
- sha1: string;
- size: number;
- url: string;
- };
- classifiers?: {
- javadoc?: {
- path: string;
- sha1: string;
- size: number;
- url: string;
- };
- "natives-osx"?: {
- path: string;
- sha1: string;
- size: number;
- url: string;
- };
- sources?: {
- path: string;
- sha1: string;
- size: number;
- url: string;
- };
- "natives-linux"?: {
- path: string;
- sha1: string;
- size: number;
- url: string;
- };
- "natives-windows"?: {
- path: string;
- sha1: string;
- size: number;
- url: string;
- };
- "natives-macos"?: {
- path: string;
- sha1: string;
- size: number;
- url: string;
- };
- };
- };
- name: string;
- rules?: Array<{
- action: string;
- os?: {
- name: string;
- };
- }>;
- natives?: {
- osx?: string;
- linux?: string;
- windows?: string;
- };
- extract?: {
- exclude: Array;
- };
- }>;
- logging: {
- client: {
- argument: string;
- file: {
- id: string;
- sha1: string;
- size: number;
- url: string;
- };
- type: string;
- };
- };
- mainClass: string;
- minimumLauncherVersion: number;
- releaseTime: string;
- time: string;
- type: string;
-};
diff --git a/src/fetchVersion/types/Java.js b/src/fetchVersion/types/Java.js
deleted file mode 100644
index c8ad2e5..0000000
--- a/src/fetchVersion/types/Java.js
+++ /dev/null
@@ -1,2 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
diff --git a/src/index.d.ts b/src/index.d.ts
deleted file mode 100644
index fb3c6d7..0000000
--- a/src/index.d.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-import type { bedrockSchema } from "./db/bedrock";
-import type { javaSchema } from "./db/java";
-import type { paperSchema } from "./db/paper";
-import type { powernukkitSchema } from "./db/powernukkit";
-import type { pocketminemmpSchema } from "./db/pocketmine";
-import type { spigotSchema } from "./db/spigot";
-export declare type BdsCorePlatforms = "bedrock" | "java" | "paper" | "powernukkit" | "pocketmine" | "spigot";
-export declare type all = bedrockSchema | javaSchema | powernukkitSchema | paperSchema | pocketminemmpSchema | spigotSchema;
-export type { bedrockSchema as bedrock, javaSchema as java, paperSchema as paper, pocketminemmpSchema as pocketmine, spigotSchema as spigot, powernukkitSchema as powernukkit };
-export declare function findVersion(bdsPlaform: BdsCorePlatforms): Promise;
-export declare function findVersion(bdsPlaform: BdsCorePlatforms, version: string | boolean): Promise;
-export declare function findVersion(bdsPlaform: BdsCorePlatforms, version: string | boolean, ignoreStatic: boolean): Promise;
-export declare const platformManeger: {
- bedrock: {
- all(): Promise;
- find(version: string | boolean): Promise;
- };
- pocketmine: {
- all(): Promise;
- find(version: string | boolean): Promise;
- };
- powernukkit: {
- all(): Promise;
- find(version: string | boolean): Promise;
- };
- java: {
- all(): Promise;
- find(version: string | boolean): Promise;
- };
- spigot: {
- all(): Promise;
- find(version: string | boolean): Promise;
- };
- paper: {
- all(): Promise;
- find(version: string | boolean, build?: number | string): Promise;
- };
-};
diff --git a/src/index.js b/src/index.js
deleted file mode 100644
index 8a704f3..0000000
--- a/src/index.js
+++ /dev/null
@@ -1,80 +0,0 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.platformManeger = exports.findVersion = void 0;
-const core_utils_1 = require("@the-bds-maneger/core-utils");
-async function findVersion(bdsPlaform, version, ignoreStatic) {
- const versionURLs = ["https://mcpeversions_backup.sirherobrine23.org", "https://mcpeversions.sirherobrine23.org"];
- if (!ignoreStatic)
- versionURLs.push("https://mcpeversion-static.sirherobrine23.org/");
- else
- console.warn("Using dynamic APIs, some may be down!");
- for (let url of versionURLs.reverse()) {
- url += "/" + bdsPlaform;
- if (/static/.test(url)) {
- if (version === undefined)
- url += "/all.json";
- else if (typeof version === "boolean")
- url += "/latest.json";
- else
- url += `/${version}.json`;
- }
- else {
- if (version === undefined || version === "all")
- url += "/";
- else {
- if (typeof version === "boolean" || version === "latest")
- url += "/latest";
- else
- url += `/search?version=${version}`;
- }
- }
- const res = await core_utils_1.httpRequest.bufferFetch(url).then(({ data }) => data).catch(() => false);
- if (res === false)
- continue;
- const data = JSON.parse(res.toString("utf8"), (key, value) => key === "date" ? new Date(value) : value);
- if (!data)
- throw new Error("Failed to get data");
- return data;
- }
- throw new Error("Failed to exec API request!");
-}
-exports.findVersion = findVersion;
-exports.platformManeger = {
- bedrock: {
- async all() { return core_utils_1.httpRequest.getJSON("https://the-bds-maneger.github.io/BedrockFetch/all.json"); },
- async find(version) {
- const all = await core_utils_1.httpRequest.getJSON("https://the-bds-maneger.github.io/BedrockFetch/all.json");
- if (typeof version === "boolean" || version.toLowerCase().trim() === "latest")
- return all.at(-1);
- const rel = all.find(rel => rel.version === version);
- if (!rel)
- throw new Error("Version not found");
- return rel;
- }
- },
- pocketmine: {
- async all() { return findVersion("pocketmine"); },
- async find(version) { return findVersion("pocketmine", version); }
- },
- powernukkit: {
- async all() { return findVersion("powernukkit"); },
- async find(version) { return findVersion("powernukkit", version); }
- },
- java: {
- async all() { return findVersion("java"); },
- async find(version) { return findVersion("java", version); }
- },
- spigot: {
- async all() { return findVersion("spigot"); },
- async find(version) { return findVersion("spigot", version); }
- },
- paper: {
- async all() { return findVersion("paper"); },
- async find(version, build) {
- var _a;
- if (!build)
- build = (_a = (await findVersion("paper")).find(ver => ver.version === version)) === null || _a === void 0 ? void 0 : _a.build;
- return findVersion("paper", `${version}${!!build ? "_" + build : ""}`);
- }
- }
-};