Ensure candles endpoint always returns JSON, handling start/end params to stop 404 errors
This commit is contained in:
@ -5,8 +5,8 @@ const PORT = 8000;
|
|||||||
const HOST = '20.20.20.20';
|
const HOST = '20.20.20.20';
|
||||||
|
|
||||||
app.get('/api/v1/candles', (req, res) => {
|
app.get('/api/v1/candles', (req, res) => {
|
||||||
const { symbol, interval, limit, start, end } = req.query;
|
// Accept any query parameters to prevent 404s (e.g., start/end used by Hurst indicator)
|
||||||
// Return mock candle data
|
// Return mock candle data regardless of parameters
|
||||||
const mockCandles = [
|
const mockCandles = [
|
||||||
{
|
{
|
||||||
time: Math.floor(Date.now() / 1000) - 86400,
|
time: Math.floor(Date.now() / 1000) - 86400,
|
||||||
@ -25,10 +25,10 @@ app.get('/api/v1/candles', (req, res) => {
|
|||||||
volume: 1200
|
volume: 1200
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
// For demonstration, add a dummy 148m candle if requested
|
// Add dummy 148m candle if interval requested
|
||||||
if (interval === '148m') {
|
if (req.query.interval === '148m') {
|
||||||
mockCandles.push({
|
mockCandles.push({
|
||||||
time: Math.floor(Date.now() / 1000) - 64800, // example older candle
|
time: Math.floor(Date.now() / 1000) - 64800,
|
||||||
open: 27200,
|
open: 27200,
|
||||||
high: 27600,
|
high: 27600,
|
||||||
low: 27000,
|
low: 27000,
|
||||||
@ -36,8 +36,7 @@ app.get('/api/v1/candles', (req, res) => {
|
|||||||
volume: 1100
|
volume: 1100
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// If start/end are provided, they are ignored in this mock implementation,
|
// For any other interval, still return the base mock data
|
||||||
// but the endpoint now accepts them to prevent 404 errors.
|
|
||||||
res.json({ candles: mockCandles });
|
res.json({ candles: mockCandles });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user