veza/veza-backend-api/internal/api/routes_distribution.go
senke a15bdb965d feat(v0.12.2): F501-F510 distribution service, handler, and routes
- Distribution module: submit tracks to Spotify, Apple Music, Deezer
- Subscription eligibility check (Creator/Premium only)
- Distribution status tracking with platform-specific statuses
- Status history audit trail
- External streaming royalties import and aggregation
- Distributor provider interface for DistroKid/TuneCore integration
- Handler and service unit tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 19:54:26 +01:00

41 lines
1.4 KiB
Go

package api
import (
"github.com/gin-gonic/gin"
"veza-backend-api/internal/core/distribution"
"veza-backend-api/internal/core/subscription"
"veza-backend-api/internal/handlers"
)
// setupDistributionRoutes configures routes for track distribution to external platforms (v0.12.2)
func (r *APIRouter) setupDistributionRoutes(router *gin.RouterGroup) {
subSvc := subscription.NewService(r.db.GormDB, r.logger)
svc := distribution.NewService(r.db.GormDB, r.logger, subSvc)
handler := handlers.NewDistributionHandler(svc, r.logger)
if r.config.AuthMiddleware == nil {
return
}
// Distribution management (requires auth)
distGroup := router.Group("/distributions")
distGroup.Use(r.config.AuthMiddleware.RequireAuth())
r.applyCSRFProtection(distGroup)
distGroup.POST("/submit", handler.Submit)
distGroup.GET("", handler.ListDistributions)
distGroup.GET("/:id", handler.GetDistribution)
distGroup.GET("/:id/status-history", handler.GetStatusHistory)
distGroup.POST("/:id/remove", handler.RemoveDistribution)
// Track-specific distribution view
trackDistGroup := router.Group("/tracks")
trackDistGroup.Use(r.config.AuthMiddleware.RequireAuth())
trackDistGroup.GET("/:track_id/distributions", handler.GetTrackDistributions)
// External royalties (creator view)
creatorGroup := router.Group("/creators/me")
creatorGroup.Use(r.config.AuthMiddleware.RequireAuth())
creatorGroup.GET("/external-royalties", handler.GetExternalRoyalties)
}