fix: convert timestamp columns to Unix epoch seconds in candles and annotations API
This commit is contained in:
parent
a9bfe36e47
commit
04a8303f4f
2 changed files with 12 additions and 2 deletions
|
|
@ -29,7 +29,12 @@ export async function GET(request: NextRequest) {
|
|||
.where(eq(candles.chart_id, parseInt(chartId, 10)))
|
||||
.orderBy(asc(candles.time));
|
||||
|
||||
return NextResponse.json(allCandles);
|
||||
const normalized = allCandles.map((c) => ({
|
||||
...c,
|
||||
time: c.time instanceof Date ? Math.floor(c.time.getTime() / 1000) : c.time,
|
||||
}));
|
||||
|
||||
return NextResponse.json(normalized);
|
||||
} catch (error: any) {
|
||||
return NextResponse.json(
|
||||
{ error: error.message || 'Failed to fetch candles' },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue