| 1121 | } |
| 1122 | |
| 1123 | function handleExportStatus(req, res, url) { |
| 1124 | const id = url.searchParams.get("id"); |
| 1125 | const job = exportJobs.get(id); |
| 1126 | if (!job) return json(res, 404, { error: "Export job not found" }); |
| 1127 | json(res, 200, { |
| 1128 | id: job.id, |
| 1129 | status: job.status, |
| 1130 | percent: job.percent, |
| 1131 | message: job.message, |
| 1132 | url: job.status === "complete" ? job.url : null, |
| 1133 | path: job.status === "complete" ? job.output : null, |
| 1134 | error: job.error, |
| 1135 | detail: job.status === "error" ? job.stderr : "" |
| 1136 | }); |
| 1137 | } |
| 1138 | |
| 1139 | async function handleRequest(req, res) { |
| 1140 | const url = new URL(req.url, `http://${req.headers.host}`); |