Add dotenv package for environment variable management and update pnpm-lock.yaml. Adjust layout in RegisterPage and LoginPage components for improved responsiveness. Enhance AdminPanel with ChallengeManagement section and update navigation links for challenges. Refactor Prisma schema to include Challenge model and related enums.
Some checks failed
Deploy with Docker Compose / deploy (push) Failing after 3m2s
Some checks failed
Deploy with Docker Compose / deploy (push) Failing after 3m2s
This commit is contained in:
25
app/api/challenges/route.ts
Normal file
25
app/api/challenges/route.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
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({ error: "Vous devez être connecté" }, { status: 401 });
|
||||
}
|
||||
|
||||
// Récupérer tous les défis de l'utilisateur
|
||||
const challenges = await challengeService.getUserChallenges(session.user.id);
|
||||
|
||||
return NextResponse.json(challenges);
|
||||
} catch (error) {
|
||||
console.error("Error fetching challenges:", error);
|
||||
return NextResponse.json(
|
||||
{ error: "Erreur lors de la récupération des défis" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user