import { getDb, newId, nowIso } from '../../../../../../lib/db.js';
export const dynamic='force-dynamic'; export const runtime='nodejs';
export async function POST(_r,{params}){ const {id}=await params; const db=getDb(); const file=db.prepare('SELECT * FROM disk_files WHERE id=?').get(id); if(!file) return Response.json({error:'not found'},{status:404}); const task_id=newId('hbtask'); const now=nowIso(); db.prepare(`INSERT INTO heartbeat_tasks (id, project_id, type, status, priority, payload, attempts, max_attempts, run_after, created_at, updated_at) VALUES (?, ?, 'transcribe_audio', 'queued', 0, ?, 0, 3, ?, ?, ?)`).run(task_id, file.project_id, JSON.stringify({file_id:id, project_id:file.project_id}), now, now, now); return Response.json({status:'enqueued', task_id}); }
