888
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || "/api";
|
||||
const API_BASE_URL = import.meta.env?.VITE_API_BASE_URL || "/api";
|
||||
|
||||
async function request(path, options = {}) {
|
||||
const response = await fetch(`${API_BASE_URL}${path}`, {
|
||||
@@ -33,6 +33,18 @@ export const api = {
|
||||
const params = new URLSearchParams(query).toString();
|
||||
return request(`/db/tables/${tableName}/rows${params ? `?${params}` : ""}`);
|
||||
},
|
||||
createRow: (tableName, body) => request(`/db/tables/${tableName}/rows`, { method: "POST", body: JSON.stringify(body) }),
|
||||
updateRow: (tableName, id, body) =>
|
||||
request(`/db/tables/${tableName}/rows/${id}`, { method: "PUT", body: JSON.stringify(body) }),
|
||||
deleteRow: (tableName, id) => request(`/db/tables/${tableName}/rows/${id}`, { method: "DELETE" }),
|
||||
addColumn: (tableName, body) =>
|
||||
request(`/db/tables/${tableName}/columns`, { method: "POST", body: JSON.stringify(body) }),
|
||||
alterColumn: (tableName, columnName, body) =>
|
||||
request(`/db/tables/${tableName}/columns/${columnName}`, { method: "PATCH", body: JSON.stringify(body) }),
|
||||
dropColumn: (tableName, columnName) => request(`/db/tables/${tableName}/columns/${columnName}`, { method: "DELETE" }),
|
||||
createIndex: (tableName, body) =>
|
||||
request(`/db/tables/${tableName}/indexes`, { method: "POST", body: JSON.stringify(body) }),
|
||||
dropIndex: (tableName, indexName) => request(`/db/tables/${tableName}/indexes/${indexName}`, { method: "DELETE" }),
|
||||
executeSql: (sql) => request("/sql/execute", { method: "POST", body: JSON.stringify({ sql }) }),
|
||||
users: () => request("/admin/users"),
|
||||
roles: () => request("/admin/roles"),
|
||||
|
||||
Reference in New Issue
Block a user