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
This commit is contained in:
Marko Djordjevic 2026-02-12 10:24:03 +01:00
parent d04b673cfa
commit 096a80b229
5 changed files with 312 additions and 0 deletions

View file

@ -0,0 +1,20 @@
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 }
);
}
}