export default class HttpClient { private static instance: HttpClient; baseURL: string; private constructor(baseURL: string) { this.baseURL = baseURL; } private getURL(endpoint: string): URL { return new URL(endpoint, this.baseURL) } public static getInstance(): HttpClient { if (!HttpClient.instance) { const baseUrl = import.meta.env?.VITE_API_BASE_URL ?? 'http://localhost:8080/api/v1'; HttpClient.instance = new HttpClient(baseUrl); } return HttpClient.instance; } async get({ endpoint }: IHttpParameters): Promise { const url = this.getURL(endpoint); const response = await fetch(url, { method: 'GET', headers: headers, }); return response.json(); } async post({ endpoint }: IHttpParameters): Promise { const url = this.getURL(endpoint); const response = await fetch(url, { method: 'POST', body: JSON.stringify(body), headers: headers, }); return response.json(); } async patch({ endpoint, authenticated, headers }: IHttpParameters): Promise { const url = this.getURL(endpoint); if (authenticated) { } const response: Response = await fetch(url) } async delete({ endpoint, authenticated }: IHttpParameters): Promise { const url = this.getURL(endpoint); if (authenticated) { } const response = await fetch() } } interface IHttpParameters { endpoint: string; authenticated: boolean; headers: Headers }