All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 6m16s
24 lines
590 B
TypeScript
24 lines
590 B
TypeScript
import { NextResponse } from "next/server";
|
|
import { auth } from "@/lib/auth";
|
|
import { challengeService } from "@/services/challenges/challenge.service";
|
|
|
|
export async function GET() {
|
|
try {
|
|
const session = await auth();
|
|
|
|
if (!session?.user?.id) {
|
|
return NextResponse.json({ count: 0 });
|
|
}
|
|
|
|
const count = await challengeService.getActiveChallengesCount(
|
|
session.user.id
|
|
);
|
|
|
|
return NextResponse.json({ count });
|
|
} catch (error) {
|
|
console.error("Error fetching active challenges count:", error);
|
|
return NextResponse.json({ count: 0 });
|
|
}
|
|
}
|
|
|