import type { PageServerLoad } from './$types'; import { getDb } from '$lib/server/db'; import { scanLibraries } from '$lib/server/scanner'; export const load: PageServerLoad = async ({ parent }) => { const { loggedIn } = await parent(); const db = getDb(); scanLibraries(db); const games = loggedIn ? db .prepare( `SELECT id, slug, title, library, has_cover, has_wide, genre FROM games ORDER BY title ASC` ) .all() : db .prepare( `SELECT id, slug, title, library, has_cover, has_wide, genre FROM games WHERE library = 'public' ORDER BY title ASC` ) .all(); return { games }; };