package api

import (
	"log/slog"
	"net/http"
)

// listProxyRoutes handles GET /api/proxies.
// Returns all proxy-enabled instances with project and stage names.
func (s *Server) listProxyRoutes(w http.ResponseWriter, r *http.Request) {
	settings, err := s.store.GetSettings()
	if err != nil {
		slog.Error("failed to get settings for proxy routes", "error", err)
		respondError(w, http.StatusInternalServerError, "internal server error")
		return
	}

	routes, err := s.store.ListProxyRoutes(settings.Domain)
	if err != nil {
		slog.Error("failed to list proxy routes", "error", err)
		respondError(w, http.StatusInternalServerError, "internal server error")
		return
	}

	respondJSON(w, http.StatusOK, routes)
}
