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

export const client = ky.create({
	prefixUrl: '/api',
	credentials: 'include'
});
// TODO: make wrapper for apiclient fr
export const api = {
		file: async (file_id: string) => await client.get(file_id),
		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, file: string) => {
				return await client.delete(`${uid}/${file}`).json();
		},
}