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:
parent
d04b673cfa
commit
096a80b229
5 changed files with 312 additions and 0 deletions
20
src/app/api/candles/route.ts
Normal file
20
src/app/api/candles/route.ts
Normal 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 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue