Files
whattoplay/scripts/test-backend.mjs

55 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
/**
* Standalone Backend-Test
* Testet die API-Funktionen direkt ohne Vite-Server
*/
import { readFile } from "node:fs/promises";
import { fileURLToPath } from "node:url";
import { dirname, join } from "node:path";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const rootDir = join(__dirname, "..");
console.log("=".repeat(60));
console.log("Backend API Test");
console.log("=".repeat(60));
// Test 1: Config File lesen
console.log("\n[TEST 1] Config File direkt lesen");
console.log("-".repeat(60));
const configPath = join(rootDir, "config.local.json");
console.log("Config Pfad:", configPath);
try {
const configRaw = await readFile(configPath, "utf-8");
console.log("\n✓ Datei gelesen, Größe:", configRaw.length, "bytes");
console.log("\nInhalt:");
console.log(configRaw);
const config = JSON.parse(configRaw);
console.log("\n✓ JSON parsing erfolgreich");
console.log("\nGeparste Config:");
console.log(JSON.stringify(config, null, 2));
if (config.steam?.apiKey && config.steam?.steamId) {
console.log("\n✓ Steam-Daten vorhanden:");
console.log(" - API Key:", config.steam.apiKey.substring(0, 8) + "...");
console.log(" - Steam ID:", config.steam.steamId);
} else {
console.log("\n⚠ Steam-Daten nicht vollständig");
}
} catch (error) {
console.error("\n❌ Fehler beim Lesen der Config:");
console.error(" Error:", error.message);
console.error(" Stack:", error.stack);
process.exit(1);
}
console.log("\n" + "=".repeat(60));
console.log("✓ Alle Tests bestanden!");
console.log("=".repeat(60));