#!/usr/bin/env node import fetch from 'node-fetch'; async function testAPIConnection() { console.log('πŸ§ͺ Testing API Connection...'); const baseURL = 'https://vollidioten.ceraticsoft.de'; try { // Test basic API status console.log('πŸ“‘ Testing API status...'); const statusResponse = await fetch(`${baseURL}/api/status`); if (statusResponse.ok) { const statusData = await statusResponse.json(); console.log('βœ… API Status:', statusData); } else { console.log('❌ API Status failed:', statusResponse.status); } // Test map metadata endpoint console.log('πŸ—ΊοΈ Testing map metadata endpoint...'); const metadataResponse = await fetch(`${baseURL}/api/map/metadata`); if (metadataResponse.ok) { const metadata = await metadataResponse.json(); console.log('βœ… Map metadata:', metadata); } else { console.log('⚠️ Map metadata not available (this is expected if map not assembled):', metadataResponse.status); } // Test layers endpoint console.log('πŸ“Š Testing layers endpoint...'); const layersResponse = await fetch(`${baseURL}/api/map/layers`); if (layersResponse.ok) { const layers = await layersResponse.json(); console.log('βœ… Layers:', layers.length, 'layers found'); } else { console.log('❌ Layers endpoint failed:', layersResponse.status); } // Test markers endpoint console.log('πŸ“ Testing markers endpoint...'); const markersResponse = await fetch(`${baseURL}/api/map/markers/public`); if (markersResponse.ok) { const markers = await markersResponse.json(); console.log('βœ… Markers:', markers.length, 'markers found'); } else { console.log('❌ Markers endpoint failed:', markersResponse.status); } console.log('\nπŸŽ‰ API connection test completed!'); } catch (error) { console.error('❌ API connection test failed:', error.message); console.log('\nπŸ’‘ Troubleshooting tips:'); console.log('1. Check if the backend server is running'); console.log('2. Verify the API endpoints are accessible'); console.log('3. Check for CORS issues'); console.log('4. Ensure the database is connected'); } } testAPIConnection();