feat: add React frontend and serve it from Express
Also fixes a Windows-specific bug in worker.js and cleanup.js: the
"run only if executed directly" guard compared import.meta.url against
`file://${process.argv[1]}`, which never matches on Windows (backslash
path separators, missing extra slash before the drive letter). main()
silently never ran, so the worker process started and exited
immediately without ever polling. Caught during this task's manual
verification of the full upload-convert-download flow. Fixed with
node:url's pathToFileURL, which builds a correct file:// URL cross-platform.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
export async function fetchFormats(source) {
|
||||
const response = await fetch(`/api/formats?source=${encodeURIComponent(source)}`);
|
||||
const data = await response.json();
|
||||
return data.targets;
|
||||
}
|
||||
|
||||
export async function uploadFiles(items) {
|
||||
const formData = new FormData();
|
||||
const targetFormats = [];
|
||||
for (const item of items) {
|
||||
formData.append('files', item.file);
|
||||
targetFormats.push(item.targetFormat);
|
||||
}
|
||||
formData.append('targetFormats', JSON.stringify(targetFormats));
|
||||
|
||||
const response = await fetch('/api/jobs', { method: 'POST', body: formData });
|
||||
const data = await response.json();
|
||||
return data.jobs;
|
||||
}
|
||||
|
||||
export async function fetchJobStatus(id) {
|
||||
const response = await fetch(`/api/jobs/${id}`);
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export function downloadUrl(id) {
|
||||
return `/api/jobs/${id}/download`;
|
||||
}
|
||||
Reference in New Issue
Block a user