import ky from 'ky';
import { StereoFile } from './types';

export const client = ky.create({
	prefixUrl: '/api',
	credentials: 'include'
});

export const api = {
		file: async (uid: string) => await client.get<Blob>(uid),
		list: async () => await client.get('list').json<StereoFile[]>(),
		upload: async (file: File) => {
				const formData = new FormData();
				formData.append('file', file);
				return await client.post('upload', { body: formData });
		},
		delete: async (uid: string) => await client.delete(uid).json(),
}