Files
hoerdle/app/api/daily/route.ts
2025-11-22 11:56:16 +01:00

22 lines
691 B
TypeScript

import { NextResponse } from 'next/server';
import { getOrCreateDailyPuzzle } from '@/lib/dailyPuzzle';
export async function GET(request: Request) {
try {
const { searchParams } = new URL(request.url);
const genreName = searchParams.get('genre');
const puzzle = await getOrCreateDailyPuzzle(genreName);
if (!puzzle) {
return NextResponse.json({ error: 'Failed to get or create puzzle' }, { status: 404 });
}
return NextResponse.json(puzzle);
} catch (error) {
console.error('Error fetching daily puzzle:', error);
return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 });
}
}