discover servers

This commit is contained in:
tresabhi committed 2026-06-24 20:21:05 -05:00
1 parent c292ddcd6a
commit b285e9f1d0
7 files changed
+59 -348

No files matched your search

+6 -4
View File
@@ -22,6 +22,8 @@ import { merge } from "lodash-es";
import { parse } from "yaml";
import { AbstractAPI, Cache } from "./abstract";
const temp = assertSecret(import.meta.env.TEMP);
if (typeof window !== "undefined") {
throw new Error("ServerAPI is being evaluated in the browser");
}
@@ -138,7 +140,7 @@ export class ServerAPI extends AbstractAPI {
@Cache()
async popularTanks() {
if (!existsSync("../../temp/popular.json")) {
if (!existsSync(`${temp}/popular.json`)) {
const { tanks } = await this.tanks();
const tanksArray = Object.values(tanks);
@@ -212,13 +214,13 @@ export class ServerAPI extends AbstractAPI {
.map(([id, views]) => ({ id, views })),
} satisfies PopularTanks;
await mkdir("../../temp", { recursive: true });
await writeFile("../../temp/popular.json", JSON.stringify(popularTanks));
await mkdir(temp, { recursive: true });
await writeFile(`${temp}/popular.json`, JSON.stringify(popularTanks));
return popularTanks;
}
const data = await readFile("../../temp/popular.json", "utf-8");
const data = await readFile(`${temp}/popular.json`, "utf-8");
return JSON.parse(data) as PopularTanks;
}
+1 -1
View File
@@ -12,7 +12,7 @@ if (!clientUnmounted && import.meta.env.SSR) {
_game = new GameInterface(
assertSecret(import.meta.env.PUBLIC_WOTB_CLIENT),
assertSecret(import.meta.env.WOTB_USMAP),
"../../temp",
assertSecret(import.meta.env.TEMP),
Number(assertSecret(import.meta.env.TEXTURE_CHUNKS)),
);