package httpapi import ( "net/http" "watch-party-backend/internal/repo" "watch-party-backend/internal/service" "github.com/gin-gonic/gin" ) func NewRouter(svc service.EpisodeService) *gin.Engine { r := gin.New() r.Use(gin.Logger(), gin.Recovery()) r.GET("/healthz", func(c *gin.Context) { c.JSON(http.StatusOK, gin.H{"status": "ok"}) }) r.GET("/current", func(c *gin.Context) { cur, err := svc.GetCurrent(c.Request.Context()) if err != nil { if err == repo.ErrNotFound { c.JSON(http.StatusNotFound, gin.H{"error": "no current row found"}) return } c.JSON(http.StatusInternalServerError, gin.H{"error": "query failed"}) return } c.JSON(http.StatusOK, cur) }) return r }