Files

35 lines
1.3 KiB
JavaScript

async function main() {
const authRes = await fetch('https://auth.ghaymah.systems/signin/email-password', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email: 'ziadalex2003@gmail.com', password: '2062003Mz*' })
});
const { session } = await authRes.json();
const token = session.accessToken;
const userId = session.user.id;
const res = await fetch('https://graphql.ghaymah.systems/v1/graphql', {
method: 'POST',
headers: { 'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json' },
body: JSON.stringify({
query: `query GetResources($userId: uuid) {
ghaymah_cloud_resources(where: { user_id: { _eq: $userId }, deleted: { _eq: false }, chart_name: { _eq: "ghaymah-app" } }) {
id status values message
}
}`,
variables: { userId }
})
});
const data = await res.json();
data.data.ghaymah_cloud_resources.forEach(a => {
console.log('=== ' + a.values.name + ' ===');
console.log('ID:', a.id);
console.log('Status:', a.status);
console.log('Message:', a.message);
console.log('Ports:', JSON.stringify(a.values.ports));
console.log('PublicAccess:', JSON.stringify(a.values.publicAccess));
console.log('Command:', JSON.stringify(a.values.command)?.substring(0, 200));
});
}
main().catch(console.error);