Files
football-next/app/api/leaderboard/route.ts
a.alinaghipour aa9ed69dd2 first commit
2026-04-05 15:53:20 +03:30

21 lines
486 B
TypeScript

import { NextResponse } from "next/server";
import { db } from "@/lib/db";
export async function GET() {
const teams = await db.team.findMany({
orderBy: { totalPoints: "desc" },
include: { user: { select: { name: true, email: true } } },
take: 50,
});
return NextResponse.json(
teams.map((t, i) => ({
rank: i + 1,
teamName: t.name,
userName: t.user.name ?? t.user.email,
totalPoints: t.totalPoints,
budget: t.budget,
}))
);
}