- CSV upload with papaparse (handles date strings and Unix timestamps) - Annotations CRUD (GET, POST, DELETE) - Candles GET endpoint - Export annotations as CSV
20 lines
490 B
TypeScript
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 }
|
|
);
|
|
}
|
|
}
|