44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import { NextResponse } from "next/server";
|
|
import { sitePreferencesService } from "@/services/preferences/site-preferences.service";
|
|
|
|
export async function GET() {
|
|
try {
|
|
// Récupérer les préférences globales du site (pas besoin d'authentification)
|
|
const sitePreferences = await sitePreferencesService.getSitePreferences();
|
|
|
|
// Si elles n'existent pas, retourner des valeurs par défaut
|
|
if (!sitePreferences) {
|
|
return NextResponse.json({
|
|
homeBackground: null,
|
|
eventsBackground: null,
|
|
leaderboardBackground: null,
|
|
challengesBackground: null,
|
|
profileBackground: null,
|
|
houseBackground: null,
|
|
});
|
|
}
|
|
|
|
return NextResponse.json({
|
|
homeBackground: sitePreferences.homeBackground,
|
|
eventsBackground: sitePreferences.eventsBackground,
|
|
leaderboardBackground: sitePreferences.leaderboardBackground,
|
|
challengesBackground: sitePreferences.challengesBackground,
|
|
profileBackground: sitePreferences.profileBackground,
|
|
houseBackground: sitePreferences.houseBackground,
|
|
});
|
|
} catch (error) {
|
|
console.error("Error fetching preferences:", error);
|
|
return NextResponse.json(
|
|
{
|
|
homeBackground: null,
|
|
eventsBackground: null,
|
|
leaderboardBackground: null,
|
|
challengesBackground: null,
|
|
profileBackground: null,
|
|
houseBackground: null,
|
|
},
|
|
{ status: 200 }
|
|
);
|
|
}
|
|
}
|