require("array-flat-polyfill");
const fetch = require("node-fetch");
const app = require("express")();
app.get("/", async (req, res) => {
try {
const alpha = await fetch("https://alpha.altstore.io").then(res => res.json());
const repo = await fetch("https://apps.altstore.io").then(res => res.json());
repo.apps = [ repo.apps.map(app => {
if (app.beta) {
app.beta = false;
app.name += " (Beta)";
} return app;
}), alpha.apps.filter( app => !app.name.endsWith("(Stable)") ) ].flat().sort((a, b) => a.name.localeCompare(b.name));
repo.news = [ repo.news, alpha.news ].flat();
repo.name = "AltStore (Stable + Alpha + Beta)";
res.json(repo);
} catch (e) {
console.error(e);
res.status(500).json({ name: "Error!", identifier: "error" });
}
});
app.listen(3000);