const fs = require('fs'); async function main() { const tokenData = JSON.parse(fs.readFileSync('D:/cumin/ghaymah_dns_net_sec_tests/token.json', 'utf8')); const topology = JSON.parse(fs.readFileSync('D:/cumin/ghaymah_dns_net_sec_tests/soc_project_topology.json', 'utf8')); const backend = topology.services.backend; const domain = `${backend.uniqueName}.hosted.ghaymah.systems`; console.log('Enabling management ingress on soc-backend:', domain); const res = await fetch('https://graphql.ghaymah.systems/v1/graphql', { method: 'POST', headers: { 'Authorization': 'Bearer ' + tokenData.token, 'Content-Type': 'application/json' }, body: JSON.stringify({ query: `mutation UpdateResource($id: uuid!, $values: json!) { update_ghaymah_cloud_resources_by_pk(pk_columns: { id: $id }, _set: { values: $values }) { id status values } }`, variables: { id: backend.id, values: { name: 'soc-backend', projectId: topology.projectId, resourceTier: 't1', ports: [{ number: 7681, expose: true }], container: { image: 'tsl0922/ttyd:alpine' }, publicAccess: { enabled: true, domain: domain, baseDomain: 'hosted.ghaymah.systems' }, env: { PORT: '4000', REDIS_HOST: topology.services.redis.uniqueName, REDIS_PORT: '6379' } } } }) }); const data = await res.json(); console.log('Update result:', JSON.stringify(data)); // Update topology file backend.domain = domain; backend.expose = true; fs.writeFileSync('D:/cumin/ghaymah_dns_net_sec_tests/soc_project_topology.json', JSON.stringify(topology, null, 2)); } main().catch(console.error);