const express = require('express');
const app = express();

const PORT = 8000;
const HOST = '20.20.20.20';

app.get('/api/v1/candles', (req, res) => {
  // Accept any query parameters to prevent 404s (e.g., start/end used by Hurst indicator)
  // Return mock candle data regardless of parameters
  const mockCandles = [
    {
      time: Math.floor(Date.now() / 1000) - 86400,
      open: 27000,
      high: 27500,
      low: 26900,
      close: 27300,
      volume: 1000
    },
    {
      time: Math.floor(Date.now() / 1000) - 75600,
      open: 27300,
      high: 27800,
      low: 27200,
      close: 27700,
      volume: 1200
    }
  ];
  // Add dummy 148m candle if interval requested
  if (req.query.interval === '148m') {
    mockCandles.push({
      time: Math.floor(Date.now() / 1000) - 64800,
      open: 27200,
      high: 27600,
      low: 27000,
      close: 27400,
      volume: 1100
    });
  }
  // For any other interval, still return the base mock data
  res.json({ candles: mockCandles });
});
  }
  res.json({ candles: mockCandles });
});
});

app.get('/api/v1/stats', (req, res) => {
  res.json({
    change_24h: 2.5,
    high_24h: 28000,
    low_24h: 26500
  });
});

app.get('/api/v1/ta', (req, res) => {
  res.json({
    trend: { direction: 'up', signal: 'buy' },
    levels: {
      resistance: 28000,
      support: 26500,
      position_in_range: 60
    }
  });
});

app.listen(PORT, HOST, () => {
  console.log(`API server listening on http://${HOST}:${PORT}`);
});