initial commit

This commit is contained in:
Daniel Noulet 2026-10-07 15:17:40 +02:00
parent ebd5bb09fd
commit 3046604b64
26 changed files with 1535 additions and 82 deletions

View file

@ -57,14 +57,14 @@ func FindMigrations(migrationPath string) ([]Migration, error) {
}
contentStr := string(content)
migration := parseMigration(contentStr)
migration := parseMigration(contentStr, entry.Name())
migrations = append(migrations, migration)
}
return migrations, nil
}
func parseMigration(content string) Migration {
func parseMigration(content string, filename string) Migration {
// Parse goose-style migration: -- +goose Up / -- +goose Down
lines := strings.Split(content, "\n")
var upSQL strings.Builder
@ -90,9 +90,14 @@ func parseMigration(content string) Migration {
// Extract version from filename (first part before _)
version := ""
desc := ""
if idx := strings.Index(content, "_"); idx >= 0 {
version = content[:idx]
desc = content[idx+1 : strings.Index(content, "_")] // simplistic
if idx := strings.Index(filename, "_"); idx >= 0 {
version = filename[:idx]
remaining := filename[idx+1:]
if idx2 := strings.Index(remaining, "_"); idx2 >= 0 {
desc = remaining[:idx2]
} else {
desc = strings.TrimSuffix(remaining, ".sql")
}
}
return Migration{

View file

@ -0,0 +1,34 @@
package handler
import (
"database/sql"
"log"
"net/http"
)
type Handler struct {
db *sql.DB
}
func New(db *sql.DB) *Handler {
log.Println("Handler routes registered")
return &Handler{
db: db,
}
}
func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/health":
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
w.Write([]byte(`{"status":"ok"}`))
case "/api/v1/dashboard":
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(200)
w.Write([]byte(`{"tenants":[],"applications":[],"databases":[],"is_system_administrator":false,"selected_tenant":""}`))
default:
http.NotFound(w, r)
}
}