Feat: Genre system with per-genre daily puzzles

This commit is contained in:
Hördle Bot
2025-11-22 11:56:16 +01:00
parent dc69fd1498
commit 8c720e287f
9 changed files with 294 additions and 155 deletions

View File

@@ -11,6 +11,7 @@ export async function GET() {
orderBy: { createdAt: 'desc' },
include: {
puzzles: true,
genres: true,
},
});
@@ -23,6 +24,7 @@ export async function GET() {
createdAt: song.createdAt,
coverImage: song.coverImage,
activations: song.puzzles.length,
genres: song.genres,
}));
return NextResponse.json(songsWithActivations);
@@ -144,6 +146,7 @@ export async function POST(request: Request) {
filename,
coverImage,
},
include: { genres: true }
});
return NextResponse.json({
@@ -158,15 +161,24 @@ export async function POST(request: Request) {
export async function PUT(request: Request) {
try {
const { id, title, artist } = await request.json();
const { id, title, artist, genreIds } = await request.json();
if (!id || !title || !artist) {
return NextResponse.json({ error: 'Missing fields' }, { status: 400 });
}
const data: any = { title, artist };
if (genreIds) {
data.genres = {
set: genreIds.map((gId: number) => ({ id: gId }))
};
}
const updatedSong = await prisma.song.update({
where: { id: Number(id) },
data: { title, artist },
data,
include: { genres: true }
});
return NextResponse.json(updatedSong);