candle-annotator/src/app/api/candles/route.ts
Marko Djordjevic 096a80b229 feat: implement backend API endpoints
- CSV upload with papaparse (handles date strings and Unix timestamps)
- Annotations CRUD (GET, POST, DELETE)
- Candles GET endpoint
- Export annotations as CSV
2026-02-12 10:24:03 +01:00

20 lines
490 B
TypeScript

import { NextResponse } from 'next/server';
import { db } from '@/lib/db';
import { candles } from '@/lib/db/schema';
import { asc } from 'drizzle-orm';
export async function GET() {
try {
const allCandles = await db
.select()
.from(candles)
.orderBy(asc(candles.time));
return NextResponse.json(allCandles);
} catch (error: any) {
return NextResponse.json(
{ error: error.message || 'Failed to fetch candles' },
{ status: 500 }
);
}
}