aboutsummaryrefslogtreecommitdiff
path: root/backend/api/routes.go
diff options
context:
space:
mode:
Diffstat (limited to 'backend/api/routes.go')
-rw-r--r--backend/api/routes.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/backend/api/routes.go b/backend/api/routes.go
new file mode 100644
index 0000000..fd3b8cc
--- /dev/null
+++ b/backend/api/routes.go
@@ -0,0 +1,41 @@
1package api
2
3import (
4 "github.com/gin-gonic/gin"
5 "github.com/pektezol/leastportalshub/backend/handlers"
6 swaggerfiles "github.com/swaggo/files"
7 ginSwagger "github.com/swaggo/gin-swagger"
8)
9
10func InitRoutes(router *gin.Engine) {
11 api := router.Group("/api")
12 {
13 v1 := api.Group("/v1")
14 v1.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
15 v1.GET("/", func(c *gin.Context) {
16 c.File("docs/index.html")
17 })
18 v1.GET("/token", handlers.GetCookie)
19 v1.DELETE("/token", handlers.DeleteCookie)
20 v1.GET("/login", handlers.Login)
21 v1.GET("/profile", CheckAuth, handlers.Profile)
22 v1.PUT("/profile", CheckAuth, handlers.UpdateCountryCode)
23 v1.POST("/profile", CheckAuth, handlers.UpdateUser)
24 v1.GET("/users/:id", CheckAuth, handlers.FetchUser)
25 v1.GET("/demos", handlers.DownloadDemoWithID)
26 v1.GET("/maps/:id/summary", handlers.FetchMapSummary)
27 v1.POST("/maps/:id/summary", CheckAuth, handlers.CreateMapSummary)
28 v1.PUT("/maps/:id/summary", CheckAuth, handlers.EditMapSummary)
29 v1.DELETE("/maps/:id/summary", CheckAuth, handlers.DeleteMapSummary)
30 v1.PUT("/maps/:id/image", CheckAuth, handlers.EditMapImage)
31 v1.GET("/maps/:id/leaderboards", handlers.FetchMapLeaderboards)
32 v1.POST("/maps/:id/record", CheckAuth, handlers.CreateRecordWithDemo)
33 v1.GET("/rankings", handlers.Rankings)
34 v1.GET("/search", handlers.SearchWithQuery)
35 v1.GET("/games", handlers.FetchGames)
36 v1.GET("/games/:id", handlers.FetchChapters)
37 v1.GET("/chapters/:id", handlers.FetchChapterMaps)
38 v1.GET("/logs/score", handlers.ScoreLogs)
39 v1.GET("/logs/mod", CheckAuth, handlers.ModLogs)
40 }
41}