mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 10:42:57 +00:00
dev day #81
This commit is contained in:
+97
-12
@@ -54,6 +54,10 @@ func SetupRoutes(api *gin.RouterGroup, db *gorm.DB) {
|
||||
shortLinkController := controllers.NewShortLinkController(db)
|
||||
commentController := controllers.NewCommentController(db)
|
||||
engagementController := controllers.NewEngagementController(db, emailService)
|
||||
facrController := controllers.NewFACRController(db)
|
||||
youtubeController := controllers.NewYouTubeController(db)
|
||||
umamiController := controllers.NewUmamiController()
|
||||
imageProcessingController := &controllers.ImageProcessingController{}
|
||||
|
||||
// API v1 group
|
||||
{
|
||||
@@ -76,8 +80,6 @@ func SetupRoutes(api *gin.RouterGroup, db *gorm.DB) {
|
||||
// Public page element configurations
|
||||
api.GET("/page-elements", pageElementConfigController.GetPageElementConfigs)
|
||||
|
||||
api.GET("/clothing", clothingController.GetClothing)
|
||||
|
||||
// Public shortlink creation for visitors (same-site only)
|
||||
api.POST("/shortlinks/public", middleware.RateLimit(30, time.Minute), shortLinkController.PublicCreateShortLink)
|
||||
|
||||
@@ -404,10 +406,10 @@ func SetupRoutes(api *gin.RouterGroup, db *gorm.DB) {
|
||||
// Gallery management (admin)
|
||||
gallery := admin.Group("/gallery")
|
||||
{
|
||||
gallery.GET("/profile", galleryController.GetGalleryProfile) // Get Zonerama profile
|
||||
gallery.POST("/albums/fetch", galleryController.FetchAlbum) // Fetch single album
|
||||
gallery.DELETE("/albums/:id", galleryController.DeleteAlbum) // Delete album
|
||||
gallery.POST("/refresh", galleryController.RefreshFromZonerama) // Refresh from Zonerama
|
||||
gallery.GET("/profile", galleryController.GetGalleryProfile) // Get Zonerama profile
|
||||
gallery.POST("/albums/fetch", galleryController.FetchAlbum) // Fetch single album
|
||||
gallery.DELETE("/albums/:id", galleryController.DeleteAlbum) // Delete album
|
||||
gallery.POST("/refresh", galleryController.RefreshFromZonerama) // Refresh from Zonerama
|
||||
}
|
||||
|
||||
// Alias endpoint for saving a single Zonerama album (keeps older frontend code working)
|
||||
@@ -458,10 +460,10 @@ func SetupRoutes(api *gin.RouterGroup, db *gorm.DB) {
|
||||
{
|
||||
clothing.GET("", clothingController.GetClothingAdmin)
|
||||
clothing.GET("/:id", clothingController.GetClothingByID)
|
||||
clothing.POST("", clothingController.CreateClothing)
|
||||
clothing.PUT("/:id", clothingController.UpdateClothing)
|
||||
clothing.DELETE("/:id", clothingController.DeleteClothing)
|
||||
clothing.POST("/reorder", clothingController.UpdateClothingOrder)
|
||||
clothing.POST("", clothingController.CreateClothing)
|
||||
clothing.PUT("/:id", clothingController.UpdateClothing)
|
||||
clothing.DELETE("/:id", clothingController.DeleteClothing)
|
||||
clothing.POST("/reorder", clothingController.UpdateClothingOrder)
|
||||
}
|
||||
|
||||
// Polls management (admin)
|
||||
@@ -545,15 +547,98 @@ func SetupRoutes(api *gin.RouterGroup, db *gorm.DB) {
|
||||
// Protected routes end
|
||||
}
|
||||
|
||||
// Public sweepstakes endpoints
|
||||
RegisterAnalyticsRoutes(api, db)
|
||||
|
||||
api.GET("/umami/config", umamiController.GetUmamiConfig)
|
||||
api.POST("/umami/initialize-setup", umamiController.InitializeUmamiSetup)
|
||||
|
||||
umami := api.Group("/admin/umami")
|
||||
umami.Use(middleware.JWTAuth(db))
|
||||
umami.Use(middleware.RoleAuth("admin"))
|
||||
{
|
||||
umami.POST("/initialize", umamiController.InitializeUmami)
|
||||
umami.GET("/stats", umamiController.GetStats)
|
||||
umami.GET("/metrics/:type", umamiController.GetMetrics)
|
||||
umami.GET("/pageviews", umamiController.GetPageviews)
|
||||
}
|
||||
|
||||
RegisterContactInfoRoutes(api, db)
|
||||
|
||||
api.POST("/upload", middleware.RateLimit(30, time.Minute), baseController.UploadImage)
|
||||
|
||||
imageProcessing := api.Group("/image-processing")
|
||||
imageProcessing.Use(middleware.JWTAuth(db))
|
||||
imageProcessing.Use(middleware.CSRFProtection())
|
||||
imageProcessing.Use(middleware.RoleAuth("editor"))
|
||||
{
|
||||
imageProcessing.POST("/process", imageProcessingController.ProcessImage)
|
||||
imageProcessing.POST("/crop-upload", imageProcessingController.CropAndUpload)
|
||||
imageProcessing.POST("/quick-edit", imageProcessingController.QuickEdit)
|
||||
}
|
||||
|
||||
api.GET("/scoreboard", scoreboardController.GetPublic)
|
||||
api.GET("/scoreboard/colors/derive", scoreboardController.DeriveColors)
|
||||
|
||||
api.GET("/settings", baseController.GetPublicSettings)
|
||||
api.GET("/competition-aliases", baseController.GetPublicCompetitionAliases)
|
||||
api.GET("/public/team-logo-overrides", baseController.GetPublicTeamLogoOverrides)
|
||||
|
||||
api.GET("/articles/featured", baseController.GetFeaturedArticles)
|
||||
api.GET("/articles", baseController.GetArticles)
|
||||
api.GET("/articles/:id", baseController.GetArticle)
|
||||
api.GET("/articles/slug/:slug", baseController.GetArticleBySlug)
|
||||
api.POST("/articles/:id/read", baseController.IncrementArticleRead)
|
||||
api.POST("/articles/:id/track-view", baseController.TrackArticleView)
|
||||
api.GET("/articles/:id/match-link", baseController.GetArticleMatchLink)
|
||||
api.GET("/categories", baseController.GetCategories)
|
||||
api.GET("/youtube/videos", youtubeController.GetYouTubeVideos)
|
||||
api.GET("/about", aboutController.GetPublicAboutPage)
|
||||
api.GET("/teams", baseController.GetTeams)
|
||||
api.GET("/teams/:id", baseController.GetTeam)
|
||||
api.GET("/players", baseController.GetPlayers)
|
||||
api.GET("/players/:id", baseController.GetPlayer)
|
||||
api.GET("/sponsors", baseController.GetSponsors)
|
||||
api.GET("/banners", baseController.GetBanners)
|
||||
api.GET("/matches", baseController.GetMatches)
|
||||
api.GET("/matches/history", baseController.GetMatchesHistory)
|
||||
api.GET("/standings", baseController.GetStandings)
|
||||
|
||||
api.GET("/gallery/albums", galleryController.GetGalleryAlbums)
|
||||
api.GET("/gallery/albums/:id", galleryController.GetGalleryAlbum)
|
||||
api.GET("/gallery/proxy-image", galleryController.ProxyImage)
|
||||
|
||||
api.GET("/zonerama/album", baseController.GetZoneramaAlbum)
|
||||
api.GET("/zonerama-album", baseController.GetZoneramaAlbum)
|
||||
api.GET("/zonerama/picks", baseController.GetZoneramaPicks)
|
||||
|
||||
api.GET("/clothing", clothingController.GetClothing)
|
||||
api.GET("/sweepstakes/current", sweepstakesController.GetCurrent)
|
||||
api.GET("/sweepstakes/:id/visual", sweepstakesController.PublicVisualData)
|
||||
|
||||
api.GET("/polls", pollController.GetPolls)
|
||||
api.GET("/polls/:id", pollController.GetPoll)
|
||||
api.POST("/polls/:id/vote", middleware.RateLimit(10, time.Minute), pollController.Vote)
|
||||
api.GET("/polls/:id/results", pollController.GetPollResults)
|
||||
|
||||
api.POST("/contact", middleware.RateLimit(10, time.Minute), contactController.SubmitContactForm)
|
||||
api.POST("/newsletter/subscribe", middleware.RateLimit(30, time.Minute), contactController.SubscribeToNewsletter)
|
||||
api.POST("/newsletter/unsubscribe/:email", middleware.RateLimit(30, time.Minute), contactController.UnsubscribeFromNewsletter)
|
||||
api.POST("/newsletter/setup", middleware.RateLimit(30, time.Minute), contactController.SetupNewsletterPreferences)
|
||||
api.GET("/newsletter/preferences", contactController.GetNewsletterPreferencesByToken)
|
||||
api.POST("/newsletter/preferences", contactController.SaveNewsletterPreferencesByToken)
|
||||
api.POST("/newsletter/unsubscribe-token", contactController.UnsubscribeByToken)
|
||||
|
||||
facr := api.Group("/facr")
|
||||
{
|
||||
facr.GET("/club/search", facrController.SearchClubs)
|
||||
facr.GET("/club/:type/:id", facrController.GetClubInfo)
|
||||
facr.GET("/club/:type/:id/table", facrController.GetClubTables)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// SetupRootRoutes registers endpoints at the root (no /api prefix)
|
||||
func SetupRootRoutes(r *gin.Engine, db *gorm.DB) {
|
||||
seoController := controllers.NewSEOController(db)
|
||||
shortLinkController := controllers.NewShortLinkController(db)
|
||||
|
||||
Reference in New Issue
Block a user