diff --git a/src/app/api/annotations/route.ts b/src/app/api/annotations/route.ts index 2a49e65..41d8ef1 100644 --- a/src/app/api/annotations/route.ts +++ b/src/app/api/annotations/route.ts @@ -23,7 +23,12 @@ export async function GET(request: NextRequest) { .from(annotations) .where(eq(annotations.chart_id, parseInt(chartId, 10))); - return NextResponse.json(allAnnotations); + const normalized = allAnnotations.map((a) => ({ + ...a, + timestamp: a.timestamp instanceof Date ? Math.floor(a.timestamp.getTime() / 1000) : a.timestamp, + })); + + return NextResponse.json(normalized); } catch (error: any) { return NextResponse.json( { error: error.message || 'Failed to fetch annotations' }, diff --git a/src/app/api/candles/route.ts b/src/app/api/candles/route.ts index cce9088..8c1f734 100644 --- a/src/app/api/candles/route.ts +++ b/src/app/api/candles/route.ts @@ -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' },