const { getAuth } = require('./auth_manager'); async function main() { const td = await getAuth(); console.log('Waiting for ghaymah-soc-gateway to reach Healthy status...'); for (let i = 1; i <= 15; i++) { const res = await fetch('https://graphql.ghaymah.systems/v1/graphql', { method: 'POST', headers: { 'Authorization': 'Bearer ' + td.token, 'Content-Type': 'application/json' }, body: JSON.stringify({ query: 'mutation { listStaticApps { id name status url } }' }) }); const d = await res.json(); const app = d.data?.listStaticApps?.find(a => a.name === 'ghaymah-soc-gateway'); console.log(`[Attempt ${i}/15] Status: ${app?.status}`); if (app?.status === 'Healthy' || app?.status === 'Running' || app?.status === 'Live') { console.log('>>> APP IS LIVE! <<<'); console.log('Testing URL:', app.url); const test = await fetch(app.url); console.log('HTTP Status:', test.status); const text = await test.text(); console.log('Title:', text.match(/([^<]+)<\/title>/)?.[1]); return; } await new Promise(r => setTimeout(r, 4000)); } } main().catch(console.error);