diff --git a/src/app/api/cards/random/route.ts b/src/app/api/cards/random/route.ts new file mode 100644 index 0000000..32989ef --- /dev/null +++ b/src/app/api/cards/random/route.ts @@ -0,0 +1,13 @@ +import { NextResponse, type NextRequest } from 'next/server' +import { handleError } from '@/lib/http' +import { getCardService } from '@/services/card-service-factory' + +export async function GET(request: NextRequest) { + try { + const theme = request.nextUrl.searchParams.get('theme') || undefined + const card = await getCardService().random(theme) + return NextResponse.json(card) + } catch (error) { + return handleError(error) + } +} \ No newline at end of file diff --git a/src/app/api/themes/route.ts b/src/app/api/themes/route.ts new file mode 100644 index 0000000..c5a339f --- /dev/null +++ b/src/app/api/themes/route.ts @@ -0,0 +1,12 @@ +import { NextResponse } from 'next/server' +import { handleError } from '@/lib/http' +import { getCardService } from '@/services/card-service-factory' + +export async function GET() { + try { + const themes = await getCardService().themes() + return NextResponse.json(themes) + } catch (error) { + return handleError(error) + } +} \ No newline at end of file