2024-09-24 06:17:11 -04:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
2024-11-20 06:09:04 -05:00
|
|
|
"pcgamedb/server/handler"
|
|
|
|
"pcgamedb/server/middleware"
|
2024-09-24 06:17:11 -04:00
|
|
|
|
|
|
|
"github.com/gin-contrib/cors"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
2024-11-21 12:30:26 -05:00
|
|
|
"pcgamedb/docs"
|
2024-09-24 06:17:11 -04:00
|
|
|
|
|
|
|
swaggerfiles "github.com/swaggo/files"
|
|
|
|
ginSwagger "github.com/swaggo/gin-swagger"
|
|
|
|
)
|
|
|
|
|
|
|
|
func initRoute(app *gin.Engine) {
|
|
|
|
app.Use(cors.New(cors.Config{
|
|
|
|
AllowAllOrigins: true,
|
|
|
|
}))
|
|
|
|
|
|
|
|
GameInfoGroup := app.Group("/game")
|
2024-11-16 00:48:48 -05:00
|
|
|
GameItemGroup := GameInfoGroup.Group("/raw")
|
2024-09-24 06:17:11 -04:00
|
|
|
|
2024-11-16 00:48:48 -05:00
|
|
|
GameItemGroup.GET("/unorganized", handler.GetUnorganizedGameItemsHandler)
|
|
|
|
GameItemGroup.POST("/organize", middleware.Auth(), handler.OrganizeGameItemHandler)
|
|
|
|
GameItemGroup.GET("/id/:id", handler.GetGameItemByIDHanlder)
|
|
|
|
GameItemGroup.GET("/name/:name", handler.GetGameItemByRawNameHandler)
|
|
|
|
GameItemGroup.GET("/author/:author", handler.GetGameItemsByAuthorHandler)
|
2024-09-24 06:17:11 -04:00
|
|
|
|
|
|
|
GameInfoGroup.GET("/search", handler.SearchGamesHandler)
|
|
|
|
GameInfoGroup.GET("/name/:name", handler.GetGameInfosByNameHandler)
|
|
|
|
GameInfoGroup.GET("/platform/:platform_type/:platform_id", handler.GetGameInfoByPlatformIDHandler)
|
|
|
|
GameInfoGroup.GET("/id/:id", handler.GetGameInfoByIDHandler)
|
|
|
|
GameInfoGroup.PUT("/update", middleware.Auth(), handler.UpdateGameInfoHandler)
|
2024-09-25 09:33:46 -04:00
|
|
|
GameInfoGroup.DELETE("/id/:id", middleware.Auth(), handler.DeleteGameInfoHandler)
|
2024-09-24 06:17:11 -04:00
|
|
|
|
|
|
|
app.GET("/ranking/:type", handler.GetRankingHandler)
|
|
|
|
app.GET("/healthcheck", handler.HealthCheckHandler)
|
|
|
|
app.GET("/author", handler.GetAllAuthorsHandler)
|
|
|
|
app.POST("/clean", middleware.Auth(), handler.CleanGameHandler)
|
|
|
|
|
|
|
|
docs.SwaggerInfo.BasePath = "/api"
|
|
|
|
app.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
|
|
|
|
}
|