18 lines
634 B
TypeScript
18 lines
634 B
TypeScript
import { NextResponse } from "next/server"
|
|
import { getCollection } from "@/lib/db/mongo"
|
|
|
|
export async function GET() {
|
|
try {
|
|
const coll = await getCollection("accountPawns")
|
|
const list = await coll.find({}).sort({ createdAt: -1 }).limit(500).toArray()
|
|
const data = list.map((doc: { _id: { toString(): string }; [k: string]: unknown }) => ({
|
|
...doc,
|
|
id: doc._id.toString(),
|
|
}))
|
|
return NextResponse.json({ success: true, data })
|
|
} catch (e) {
|
|
console.error("GET /api/admin/pawns error:", e)
|
|
return NextResponse.json({ success: false, message: "数据库未连接" }, { status: 500 })
|
|
}
|
|
}
|