Simple frontend added, tests are required
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import axios from 'axios'
|
||||
|
||||
export const api = axios.create({
|
||||
baseURL: '/api',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
|
||||
export const uploadFile = async (file: File): Promise<{ task_id: string; filename: string; size: number }> => {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file)
|
||||
|
||||
const response = await api.post('/upload', formData, {
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
})
|
||||
|
||||
return response.data
|
||||
}
|
||||
|
||||
export const startSplit = async (
|
||||
task_id: string,
|
||||
tracklist: TracklistEntry[],
|
||||
options: SplitOptions
|
||||
): Promise<{ task_id: string; status: string }> => {
|
||||
const response = await api.post('/split', {
|
||||
task_id,
|
||||
tracklist,
|
||||
options,
|
||||
})
|
||||
return response.data
|
||||
}
|
||||
|
||||
export const getStatus = async (task_id: string): Promise<TaskStatus> => {
|
||||
const response = await api.get(`/status/${task_id}`)
|
||||
return response.data
|
||||
}
|
||||
|
||||
export const getDownloadUrl = (task_id: string): string => {
|
||||
return `/api/download/${task_id}`
|
||||
}
|
||||
|
||||
export const getDownloadZipUrl = (task_id: string): string => {
|
||||
return `/api/download/${task_id}/splits.zip`
|
||||
}
|
||||
Reference in New Issue
Block a user