Files
wzdj/app/api/admin/points/cards/route.ts

18 lines
643 B
TypeScript

import { NextResponse } from "next/server"
import { getCollection } from "@/lib/db/mongo"
export async function GET() {
try {
const coll = await getCollection("gamePointCards")
const list = await coll.find({}).sort({ game: 1, createdAt: -1 }).limit(500).toArray()
const data = list.map((doc: Record<string, unknown> & { _id: { toString(): string } }) => ({
...doc,
id: doc._id.toString(),
}))
return NextResponse.json({ success: true, data })
} catch (e) {
console.error("GET /api/admin/points/cards error:", e)
return NextResponse.json({ success: false, error: String(e) }, { status: 500 })
}
}