package router import ( "github.com/gin-gonic/gin" "water/api/internal/controllers" "water/api/internal/middleware" ) func SetupRouter() *gin.Engine { // Disable Console Color // gin.DisableConsoleColor() r := gin.Default() r.Use(middleware.CORSMiddleware()) r.Use(gin.Logger()) r.Use(gin.Recovery()) api := r.Group("api/v1") api.POST("/auth", controllers.AuthHandler) user := api.Group("/user/:uuid") user.Use(middleware.TokenRequired()) { user.GET("", controllers.GetUser) user.GET("preferences", controllers.GetUserPreferences) user.PATCH("preferences", controllers.UpdateUserPreferences) } stats := api.Group("/stats") stats.Use(middleware.TokenRequired()) { stats.GET("/", controllers.GetAllStatistics) stats.POST("/", controllers.PostNewStatistic) stats.GET("weekly/", controllers.GetWeeklyStatistics) stats.GET("daily/", controllers.GetDailyUserStatistics) stats.GET("user/:uuid", controllers.GetUserStatistics) stats.PATCH("user/:uuid", controllers.UpdateUserStatistic) stats.DELETE("user/:uuid", controllers.DeleteUserStatistic) } return r }