12 lines
422 B
TypeScript
12 lines
422 B
TypeScript
import { NextResponse } from 'next/server';
|
|
import { getCurrentUser } from '@/lib/server/auth';
|
|
import { listOrdersForUser } from '@/lib/server/store';
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
export async function GET() {
|
|
const user = await getCurrentUser();
|
|
if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
return NextResponse.json({ orders: await listOrdersForUser(user.id) });
|
|
}
|