import { apiRequest } from './http'; import type { StoredTexture, TextureStore, UploadedTexture } from './TextureStore'; export class HttpTextureStore implements TextureStore { constructor(private readonly endpoint: string) {} async upload(bytes: Blob | ArrayBuffer, type: string): Promise { return this.request('POST', 'textures', { bytes, type }); } async list(): Promise { return this.request('GET', 'textures'); } async delete(file: string): Promise { await this.request('DELETE', `textures/${encodeURIComponent(file)}`); } private async request( method: string, route: string, payload?: { bytes: Blob | ArrayBuffer; type: string }, ): Promise { return apiRequest(this.endpoint, method, route, { headers: payload ? { 'Content-Type': payload.type } : {}, body: payload?.bytes, }); } }