18 lines
636 B
TypeScript
18 lines
636 B
TypeScript
import { NextResponse } from "next/server"
|
|
import { getCollection } from "@/lib/db/mongo"
|
|
|
|
export async function GET() {
|
|
try {
|
|
const coll = await getCollection("pointCardOrders")
|
|
const list = await coll.find({}).sort({ 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/orders error:", e)
|
|
return NextResponse.json({ success: false, error: String(e) }, { status: 500 })
|
|
}
|
|
}
|