import fs from 'node:fs';
import { streamPathForEngine, getDiskFile } from '../../../../../../lib/disk.js';
export const dynamic='force-dynamic'; export const runtime='nodejs';
export async function GET(request,{params}){ const {id}=await params; const u=new URL(request.url); const engine=request.headers.get('x-engine') || u.searchParams.get('engine'); try{ const file=getDiskFile(id); const p=streamPathForEngine(id, engine); return new Response(fs.readFileSync(p), { headers:{ 'content-type': file?.mime_type || 'application/octet-stream' } }); }catch(e){ return Response.json({error:e.message},{status:e.code==='LOCAL_ONLY_DENIED'?403:404}); } }
