21 lines
616 B
TypeScript
21 lines
616 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { db } from "@/lib/db";
|
|
import { getApiUser } from "@/lib/apiAuth";
|
|
// GET /api/golden-cards - get current user's golden cards
|
|
export async function GET(req: NextRequest) {
|
|
const apiUser = await getApiUser(req);
|
|
if (!apiUser) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
|
|
const userId = apiUser.id;
|
|
|
|
const cards = await db.goldenCard.findMany({
|
|
where: { userId },
|
|
include: {
|
|
player: { include: { country: true } },
|
|
},
|
|
orderBy: { acquiredDate: "desc" },
|
|
});
|
|
|
|
return NextResponse.json(cards);
|
|
}
|