import http from 'http';

http.get('http://localhost:5000/api/alerts', (res) => {
    let data = '';
    res.on('data', (chunk) => { data += chunk; });
    res.on('end', () => {
        try {
            const alerts = JSON.parse(data);
            console.log('--- RECENT SIGNAL ALERTS ---');
            alerts.filter((a: any) => a.type === 'signal').slice(-3).forEach((a: any) => {
                console.log(`📍 [${new Date(a.timestamp).toLocaleTimeString()}] ${a.symbol}: ${a.message.split(':')[0]}`);
            });
        } catch (e: any) {
            console.error('Error:', e.message);
        }
    });
});
