package router import ( "github.com/gin-gonic/gin" "water/api/internal/controllers" "water/api/internal/middleware" ) func SetupRouter() *gin.Engine { r := gin.Default() r.Use(middleware.CORSMiddleware()) api := r.Group("api/v1") api.POST("/auth", controllers.AuthHandler) api.GET("/sizes", middleware.TokenRequired(), controllers.GetSizes) api.PATCH("/user/preferences", controllers.UpdateUserPreferences) user := api.Group("/user/:id") user.Use(middleware.TokenRequired()) { user.GET("", controllers.GetUser) user.GET("preferences", controllers.GetUserPreferences) } 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 }