diff --git a/server/src/index.ts b/server/src/index.ts index 90da983..f11b806 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -37,6 +37,9 @@ const ALLOWED_GUILD_IDS = (process.env.ALLOWED_GUILD_IDS ?? '') .split(',') .map((s) => s.trim()) .filter(Boolean); +// Build/Version-Infos (zur Laufzeit verfügbar machen) +const BUILD_CHANNEL = String(process.env.VITE_BUILD_CHANNEL ?? process.env.BUILD_CHANNEL ?? 'stable'); +const APP_VERSION = String(process.env.VITE_APP_VERSION ?? process.env.APP_VERSION ?? '1.0.0'); if (!DISCORD_TOKEN) { console.error('Fehlende Umgebungsvariable DISCORD_TOKEN'); @@ -387,7 +390,13 @@ app.use(express.json()); app.use(cors()); app.get('/api/health', (_req: Request, res: Response) => { - res.json({ ok: true, totalPlays: persistedState.totalPlays ?? 0, categories: (persistedState.categories ?? []).length }); + res.json({ + ok: true, + totalPlays: persistedState.totalPlays ?? 0, + categories: (persistedState.categories ?? []).length, + version: APP_VERSION, + build: BUILD_CHANNEL + }); }); // --- Admin Auth --- diff --git a/web/src/App.tsx b/web/src/App.tsx index ac0b911..4d067ec 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -53,6 +53,8 @@ export default function App() { const [totalPlays, setTotalPlays] = useState(0); const [mediaUrl, setMediaUrl] = useState(''); const [chaosMode, setChaosMode] = useState(false); + const [serverVersion, setServerVersion] = useState(''); + const [serverBuild, setServerBuild] = useState(''); const chaosTimeoutRef = useRef(null); const chaosModeRef = useRef(false); useEffect(() => { chaosModeRef.current = chaosMode; }, [chaosMode]); @@ -81,7 +83,11 @@ export default function App() { try { const cats = await fetchCategories(); setCategories(cats.categories || []); } catch {} try { const h = await fetch('/api/health').then(r => r.json()).catch(() => null); - if (h && typeof h.totalPlays === 'number') setTotalPlays(h.totalPlays); + if (h) { + if (typeof h.totalPlays === 'number') setTotalPlays(h.totalPlays); + if (typeof h.version === 'string') setServerVersion(h.version); + if (typeof h.build === 'string') setServerBuild(h.build); + } } catch {} })(); }, []); @@ -330,7 +336,7 @@ export default function App() { Jukebox 420 {import.meta.env.VITE_BUILD_CHANNEL === 'nightly' && (
- v{import.meta.env.VITE_APP_VERSION || ''} + v{serverVersion || import.meta.env.VITE_APP_VERSION || ''} • Nightly
)}