feat: add cluster & bucket management

This commit is contained in:
2024-08-16 01:23:55 +07:00
parent b0e5d53ee0
commit dfb4e30e23
41 changed files with 1394 additions and 67 deletions
+14 -6
View File
@@ -4,8 +4,6 @@ type FetchOptions = Omit<RequestInit, "headers" | "body"> & {
body?: any;
};
const ADMIN_KEY = "E1tDBf4mhc/XMHq1YJkDE6N1j3AZG9dRWR+vDDTyASk=";
const api = {
async fetch<T = any>(url: string, options?: Partial<FetchOptions>) {
const headers: Record<string, string> = {};
@@ -25,10 +23,6 @@ const api = {
headers["Content-Type"] = "application/json";
}
if (ADMIN_KEY) {
headers["Authorization"] = `Bearer ${ADMIN_KEY}`;
}
const res = await fetch(_url, {
...options,
headers: { ...headers, ...(options?.headers || {}) },
@@ -64,6 +58,20 @@ const api = {
method: "POST",
});
},
async put<T = any>(url: string, options?: Partial<FetchOptions>) {
return this.fetch<T>(url, {
...options,
method: "PUT",
});
},
async delete<T = any>(url: string, options?: Partial<FetchOptions>) {
return this.fetch<T>(url, {
...options,
method: "DELETE",
});
},
};
export default api;