Integrate GoAdmin into main API with auto-migrations

- Admin panel accessible at /admin on the same domain
- GoAdmin tables created automatically during startup migrations
- Default credentials: admin / admin

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Trey t
2025-11-26 21:12:02 -06:00
parent 736071952b
commit fff5d8c206
2 changed files with 266 additions and 0 deletions

View File

@@ -9,9 +9,11 @@ import (
"syscall"
"time"
_ "github.com/lib/pq" // PostgreSQL driver for GoAdmin
"github.com/rs/zerolog/log"
"gorm.io/gorm"
"github.com/treytartt/mycrib-api/internal/admin"
"github.com/treytartt/mycrib-api/internal/config"
"github.com/treytartt/mycrib-api/internal/database"
"github.com/treytartt/mycrib-api/internal/router"
@@ -91,6 +93,15 @@ func main() {
}
r := router.SetupRouter(deps)
// Setup GoAdmin panel at /admin
if db != nil {
if _, err := admin.Setup(r, cfg); err != nil {
log.Warn().Err(err).Msg("Failed to setup admin panel - admin will be unavailable")
} else {
log.Info().Msg("Admin panel available at /admin")
}
}
// Create HTTP server
srv := &http.Server{
Addr: fmt.Sprintf(":%d", cfg.Server.Port),