Move project files from uzdb/ subdirectory to root directory for cleaner project structure.
Changes:
- Move frontend/ to root
- Move internal/ to root
- Move build/ to root
- Move all config files (go.mod, wails.json, etc.) to root
- Remove redundant uzdb/ subdirectory nesting
Project structure is now:
├── frontend/ # React application
├── internal/ # Go backend
├── build/ # Wails build assets
├── doc/ # Design documentation
├── main.go # Entry point
└── ...
🤖 Generated with Qoder
165 lines
3.0 KiB
Markdown
165 lines
3.0 KiB
Markdown
# API Testing Guide
|
|
|
|
## Base URL
|
|
```
|
|
Development: http://localhost:8080/api
|
|
```
|
|
|
|
## Connection Management
|
|
|
|
### List all connections
|
|
```bash
|
|
curl http://localhost:8080/api/connections
|
|
```
|
|
|
|
### Create a new connection
|
|
```bash
|
|
curl -X POST http://localhost:8080/api/connections \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"name": "My Database",
|
|
"type": "mysql",
|
|
"host": "localhost",
|
|
"port": 3306,
|
|
"username": "root",
|
|
"password": "password123",
|
|
"database": "mydb"
|
|
}'
|
|
```
|
|
|
|
### Update a connection
|
|
```bash
|
|
curl -X PUT http://localhost:8080/api/connections/{id} \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"name": "Updated Name",
|
|
"host": "new-host.com"
|
|
}'
|
|
```
|
|
|
|
### Delete a connection
|
|
```bash
|
|
curl -X DELETE http://localhost:8080/api/connections/{id}
|
|
```
|
|
|
|
### Test connection
|
|
```bash
|
|
curl -X POST http://localhost:8080/api/connections/{id}/test
|
|
```
|
|
|
|
## Query Operations
|
|
|
|
### Execute a query
|
|
```bash
|
|
curl -X POST http://localhost:8080/api/query \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"connectionId": "{connection-id}",
|
|
"sql": "SELECT * FROM users LIMIT 10"
|
|
}'
|
|
```
|
|
|
|
### Get tables from a connection
|
|
```bash
|
|
curl http://localhost:8080/api/connections/{id}/tables
|
|
```
|
|
|
|
### Get table data
|
|
```bash
|
|
curl "http://localhost:8080/api/connections/{id}/tables/users/data?limit=20&offset=0"
|
|
```
|
|
|
|
### Get table structure
|
|
```bash
|
|
curl http://localhost:8080/api/connections/{id}/tables/users/structure
|
|
```
|
|
|
|
## Saved Queries
|
|
|
|
### List saved queries
|
|
```bash
|
|
curl http://localhost:8080/api/saved-queries
|
|
```
|
|
|
|
### Save a query
|
|
```bash
|
|
curl -X POST http://localhost:8080/api/saved-queries \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"name": "Daily Users Report",
|
|
"sql": "SELECT * FROM users WHERE created_at > NOW() - INTERVAL 1 DAY",
|
|
"connectionId": "{connection-id}"
|
|
}'
|
|
```
|
|
|
|
### Execute saved query
|
|
```bash
|
|
curl -X POST http://localhost:8080/api/saved-queries/{id}/execute
|
|
```
|
|
|
|
## Query History
|
|
|
|
### Get query history
|
|
```bash
|
|
curl http://localhost:8080/api/history?limit=50
|
|
```
|
|
|
|
### Clear query history
|
|
```bash
|
|
curl -X DELETE http://localhost:8080/api/history
|
|
```
|
|
|
|
## Response Format
|
|
|
|
All responses follow this format:
|
|
|
|
### Success
|
|
```json
|
|
{
|
|
"success": true,
|
|
"data": { ... },
|
|
"message": ""
|
|
}
|
|
```
|
|
|
|
### Error
|
|
```json
|
|
{
|
|
"success": false,
|
|
"data": null,
|
|
"error": "Error message here",
|
|
"code": "CONNECTION_NOT_FOUND"
|
|
}
|
|
```
|
|
|
|
## Using Wails Bindings (from Frontend)
|
|
|
|
```javascript
|
|
// Import Wails runtime
|
|
import { Events } from "@wailsio/runtime";
|
|
|
|
// Get all connections
|
|
const connections = await window.go.app.GetConnections();
|
|
|
|
// Create connection
|
|
await window.go.app.CreateConnection({
|
|
name: "Test DB",
|
|
type: "mysql",
|
|
host: "localhost",
|
|
port: 3306,
|
|
username: "root",
|
|
password: "secret",
|
|
database: "test"
|
|
});
|
|
|
|
// Execute query
|
|
const result = await window.go.app.ExecuteQuery(
|
|
connectionId,
|
|
"SELECT * FROM users"
|
|
);
|
|
|
|
console.log("Rows:", result.rows);
|
|
console.log("Columns:", result.columns);
|
|
console.log("Execution time:", result.executionTimeMs);
|
|
```
|