mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-10-18 02:52:53 +00:00
feat: Wire MVNO handlers with repository and service dependencies in carrier-connector routes
- Add logrus and gorm imports to main.go for MVNO infrastructure setup - Create logger instance and separate database connection for MVNO repository in main - Initialize GormRepository with database connection and logger - Pass repo and logger to setupRoutes for MVNO handler initialization - Replace placeholder MVNO endpoints with actual handler methods in routes.go - Create OnboardingService, MVNOHandler, and ManagementHandler instances
This commit is contained in:
@@ -14,7 +14,10 @@ import (
|
||||
"github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/repository"
|
||||
"github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/webhook"
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/sirupsen/logrus"
|
||||
csrf "github.com/utrack/gin-csrf"
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -95,7 +98,20 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
setupRoutes(router, client, profileRepo, webhookClient, messageQueue)
|
||||
// Create logger for MVNO handlers
|
||||
logger := logrus.New()
|
||||
logger.SetLevel(logrus.InfoLevel)
|
||||
|
||||
// Create separate database connection for MVNO repository
|
||||
db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
|
||||
if err != nil {
|
||||
handler.Logger.Fatal().Err(err).Msg("Failed to create database connection for MVNO repository")
|
||||
}
|
||||
|
||||
// Create repository for MVNO operations
|
||||
repo := repository.NewGormRepository(db, logger)
|
||||
|
||||
setupRoutes(router, client, profileRepo, webhookClient, messageQueue, repo, logger)
|
||||
|
||||
handler.Logger.Info().Str("port", port).Msg("Carrier Connector API server starting")
|
||||
if err := router.Run(":" + port); err != nil {
|
||||
|
||||
@@ -6,55 +6,52 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/es2"
|
||||
handler "github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/handlers"
|
||||
"github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/handlers"
|
||||
"github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/mq"
|
||||
"github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/repository"
|
||||
"github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/services"
|
||||
"github.com/nutcas3/telecom-platform/apps/carrier-connector/internal/webhook"
|
||||
)
|
||||
|
||||
// setupRoutes registers all HTTP routes, wiring the ES2+ client, profile repo, webhook client, and message queue.
|
||||
func setupRoutes(router *gin.Engine, client *es2.ES2Client, repo repository.ProfileRepository, webhookClient *webhook.WebhookClient, messageQueue *mq.MessageQueue) {
|
||||
func setupRoutes(router *gin.Engine, client *es2.ES2Client, profileRepo repository.ProfileRepository, webhookClient *webhook.WebhookClient, messageQueue *mq.MessageQueue, repo repository.Repository, logger *logrus.Logger) {
|
||||
api := router.Group("/api/v1")
|
||||
api.GET("/health", healthHandler)
|
||||
api.GET("/health/ready", readinessHandler(repo))
|
||||
api.GET("/health/ready", readinessHandler(profileRepo))
|
||||
api.GET("/health/live", livenessHandler)
|
||||
api.GET("/metrics", gin.WrapH(promhttp.Handler()))
|
||||
|
||||
esim := api.Group("/esim")
|
||||
{
|
||||
esim.POST("/profiles", handler.OrderProfileHandlerWithRepo(client, repo, webhookClient, messageQueue))
|
||||
esim.GET("/profiles", handler.ListProfilesHandler(repo))
|
||||
esim.GET("/profiles/:profileId", handler.GetProfileHandler(repo))
|
||||
esim.DELETE("/profiles/:profileId", handler.DeleteProfileHandler(repo))
|
||||
esim.POST("/profiles", handlers.OrderProfileHandlerWithRepo(client, profileRepo, webhookClient, messageQueue))
|
||||
esim.GET("/profiles", handlers.ListProfilesHandler(profileRepo))
|
||||
esim.GET("/profiles/:profileId", handlers.GetProfileHandler(profileRepo))
|
||||
esim.DELETE("/profiles/:profileId", handlers.DeleteProfileHandler(profileRepo))
|
||||
}
|
||||
|
||||
carrier := api.Group("/carrier")
|
||||
{
|
||||
carrier.GET("/info", handler.GetCarrierInfoHandler(client))
|
||||
carrier.GET("/connectivity", handler.CheckConnectivityHandler(client))
|
||||
carrier.GET("/info", handlers.GetCarrierInfoHandler(client))
|
||||
carrier.GET("/connectivity", handlers.CheckConnectivityHandler(client))
|
||||
}
|
||||
|
||||
// MVNO routes
|
||||
mvno := api.Group("/mvno")
|
||||
{
|
||||
// Note: These will be implemented with proper service initialization
|
||||
mvno.POST("/onboarding", func(c *gin.Context) {
|
||||
c.JSON(http.StatusNotImplemented, gin.H{"error": "MVNO onboarding endpoint - to be implemented"})
|
||||
})
|
||||
mvno.GET("", func(c *gin.Context) {
|
||||
c.JSON(http.StatusNotImplemented, gin.H{"error": "MVNO list endpoint - to be implemented"})
|
||||
})
|
||||
mvno.GET("/:id", func(c *gin.Context) {
|
||||
c.JSON(http.StatusNotImplemented, gin.H{"error": "MVNO get endpoint - to be implemented"})
|
||||
})
|
||||
mvno.PUT("/:id/status", func(c *gin.Context) {
|
||||
c.JSON(http.StatusNotImplemented, gin.H{"error": "MVNO status update endpoint - to be implemented"})
|
||||
})
|
||||
mvno.GET("/stats", func(c *gin.Context) {
|
||||
c.JSON(http.StatusNotImplemented, gin.H{"error": "MVNO stats endpoint - to be implemented"})
|
||||
})
|
||||
// Create MVNO handlers
|
||||
onboardingService := services.NewOnboardingService(logger)
|
||||
mvnoHandler := handlers.NewMVNOHandler(onboardingService, repo, logger)
|
||||
managementHandler := handlers.NewManagementHandler(repo, logger)
|
||||
|
||||
// MVNO onboarding and management routes
|
||||
mvno.POST("/onboarding", mvnoHandler.StartOnboarding)
|
||||
mvno.GET("", mvnoHandler.ListMVNOs)
|
||||
mvno.GET("/:id", mvnoHandler.GetMVNO)
|
||||
mvno.PUT("/:id/status", managementHandler.UpdateMVNOStatus)
|
||||
mvno.GET("/stats", managementHandler.GetMVNOStats)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user