mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
discover servers
This commit is contained in:
1 parent
c292ddcd6a
commit
b285e9f1d0
7 files changed
+59
-348
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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)),
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user