feat: implement dynamic database connection service with MySQL driver and API schema endpoints

This commit is contained in:
Ümit Tunç
2026-04-24 07:21:59 +03:00
parent 1a75c32469
commit ce67df1067
12 changed files with 417 additions and 78 deletions
+30
View File
@@ -0,0 +1,30 @@
import axios from 'axios';
import { useAppStore } from '../store/useAppStore';
const api = axios.create({
baseURL: 'http://localhost:8000/api',
});
api.interceptors.request.use((config) => {
const connection = useAppStore.getState().connection;
if (connection) {
config.params = {
...config.params,
host: connection.host,
username: connection.username,
password: connection.password,
port: connection.port,
database: connection.database || config.params?.database,
};
}
return config;
});
export default api;
export const SchemaService = {
getDatabases: () => api.get('/schema/databases'),
getTables: (db: string) => api.get(`/schema/tables/${db}`),
getTableSchema: (table: string) => api.get(`/schema/${table}`),
getTableData: (table: string, database?: string) => api.get(`/schema/${table}/data`, { params: { database } }),
};