import { json, error } from '@sveltejs/kit'; import type { RequestHandler } from './$types'; import { env } from '$env/dynamic/private'; const SCRAPER_URL = env.SCRAPER_API_URL ?? 'http://localhost:8080'; /** * GET /api/admin/scrape/status * Admin-only proxy to the Go scraper's /api/scrape/status endpoint. */ export const GET: RequestHandler = async ({ locals }) => { if (!locals.user || locals.user.role !== 'admin') { throw error(403, 'Forbidden'); } try { const res = await fetch(`${SCRAPER_URL}/api/scrape/status`); if (!res.ok) return json({ running: false }); const data = await res.json(); return json({ running: data.running ?? false }); } catch { return json({ running: false }); } };