diff --git a/src/index.ts b/src/index.ts index 238e233..5919977 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,6 +7,10 @@ import fetch from "node-fetch"; import path from "path"; import { observe, uptime } from "./stats.js"; import { getApiUrls, inviteResponse } from "./utils.js"; +import { fileURLToPath } from "url"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); interface Instance { name: string; @@ -14,7 +18,7 @@ interface Instance { } const app = express(); -import instances from "./webpage/instances.json"; +import instances from "./webpage/instances.json" assert { type: "json" }; const instanceNames = new Map(); for (const instance of instances) { @@ -28,7 +32,7 @@ async function updateInstances(): Promise { const response = await fetch( "https://raw.githubusercontent.com/spacebarchat/spacebarchat/master/instances/instances.json" ); - const json = await response.json() as Instance[]; + const json = (await response.json()) as Instance[]; for (const instance of json) { if (!instanceNames.has(instance.name)) { instances.push(instance as any); diff --git a/src/stats.ts b/src/stats.ts index af790eb..6128fba 100644 --- a/src/stats.ts +++ b/src/stats.ts @@ -2,6 +2,10 @@ import fs from "node:fs"; import path from "path"; import fetch from "node-fetch"; import { getApiUrls } from "./utils.js"; +import { fileURLToPath } from "url"; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); interface UptimeEntry { time: number; diff --git a/tsconfig.json b/tsconfig.json index 416f654..c826805 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,7 +11,7 @@ "esnext", "DOM" ], - "module": "ES2022", + "module": "ESNext", "moduleResolution": "Bundler", "newLine": "lf", "noEmitHelpers": false,