feat(api): tirage aléatoire (global ou par thème) et liste des thèmes
This commit is contained in:
1 parent
ae3e87d916
commit
19a5a47b28
2 files changed
+25
No files matched your search
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user