export default { async fetch(request) { const url = new URL(request.url); const FASTCAST_STATS = "https://eu8.fastcast4u.com/proxy/vantixradio/stats?json=1"; async function getStats(){ try { const res = await fetch( FASTCAST_STATS, { cf:{ cacheTtl:30, cacheEverything:true } } ); return await res.json(); } catch { return null; } } // API Endpoint if(url.pathname === "/api") { const stats = await getStats(); return Response.json({ station: "Vantix Radio", online: Boolean(stats), listeners: Number( stats?.currentlisteners ?? 0 ), song: stats?.songtitle ?? "Vantix Radio", updated: new Date().toISOString() }); } // HTML WEBSITE return new Response(` Vantix Radio Status
Checking...
Listeners
0
Now Playing
Loading...
`,{ headers:{ "Content-Type": "text/html" } }); } };