feat(api): tirage aléatoire (global ou par thème) et liste des thèmes

This commit is contained in:
devcodetools committed 2026-09-21 18:00:04 +02:00
1 parent ae3e87d916
commit 19a5a47b28
2 files changed
+25

No files matched your search

+13
View File
@@ -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)
}
}
+12
View File
@@ -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)
}
}