import { json } from '@sveltejs/kit'; import type { RequestHandler } from './$types'; import { getBooksWithAudioCount } from '$lib/server/pocketbase'; /** * GET /api/audio/books * Returns books that have at least one completed narrated chapter, * sorted by number of narrated chapters descending. * Cached 5 minutes at the CDN/proxy level. */ export const GET: RequestHandler = async () => { const entries = await getBooksWithAudioCount(100).catch(() => []); return json( { books: entries }, { headers: { 'Cache-Control': 'public, max-age=300' } } ); };