From dfae82694ff1f099d7af7ac7f9241c7a585f5d51 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Fri, 18 Oct 2024 00:32:53 +0300 Subject: backend: check map wr count by cm category --- backend/handlers/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backend') diff --git a/backend/handlers/user.go b/backend/handlers/user.go index 45daa31..908063f 100644 --- a/backend/handlers/user.go +++ b/backend/handlers/user.go @@ -294,7 +294,7 @@ func Profile(c *gin.Context) { } records := []ProfileRecords{} // Get singleplayer records - sql = `SELECT sp.id, m.game_id, m.chapter_id, sp.map_id, m."name", (SELECT mh.score_count FROM map_history mh WHERE mh.map_id = sp.map_id ORDER BY mh.score_count ASC LIMIT 1) AS wr_count, sp.score_count, sp.score_time, sp.demo_id, sp.record_date + sql = `SELECT sp.id, m.game_id, m.chapter_id, sp.map_id, m."name", (SELECT mh.score_count FROM map_history mh WHERE mh.map_id = sp.map_id AND mh.category_id = 1 ORDER BY mh.score_count ASC LIMIT 1) AS wr_count, sp.score_count, sp.score_time, sp.demo_id, sp.record_date FROM records_sp sp INNER JOIN maps m ON sp.map_id = m.id WHERE sp.user_id = $1 AND sp.is_deleted = false ORDER BY sp.map_id, sp.score_count, sp.score_time` rows, err = database.DB.Query(sql, user.(models.User).SteamID) if err != nil { -- cgit v1.2.3 From 3a65bca1468acffb974cde31fab3ba2c897a4184 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Fri, 18 Oct 2024 13:56:19 +0300 Subject: backend: increase file limit to 500mb --- backend/main.go | 1 + 1 file changed, 1 insertion(+) (limited to 'backend') diff --git a/backend/main.go b/backend/main.go index 306823c..e693d15 100644 --- a/backend/main.go +++ b/backend/main.go @@ -51,5 +51,6 @@ func main() { router.NoRoute(func(c *gin.Context) { c.File("../frontend/build/index.html") }) + router.MaxMultipartMemory = 500 << 20 // 500 mb limit for demos router.Run(fmt.Sprintf(":%s", os.Getenv("PORT"))) } -- cgit v1.2.3 From 71b0a39fa6cb564c96f822c37fe862f230ba8629 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Fri, 18 Oct 2024 14:53:46 +0300 Subject: backend: 200mb file limit, hide debug commands --- backend/go.mod | 1 - backend/go.sum | 2 -- backend/main.go | 38 +++++++++++++++++--------------------- 3 files changed, 17 insertions(+), 24 deletions(-) (limited to 'backend') diff --git a/backend/go.mod b/backend/go.mod index ae50685..f6eef48 100644 --- a/backend/go.mod +++ b/backend/go.mod @@ -8,7 +8,6 @@ require ( ) require ( - github.com/gin-contrib/cors v1.7.2 github.com/golang-jwt/jwt/v4 v4.5.0 github.com/google/uuid v1.6.0 github.com/pektezol/steam_go v1.1.2 diff --git a/backend/go.sum b/backend/go.sum index f117b31..10504e4 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -31,8 +31,6 @@ github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2 github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4= github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4= -github.com/gin-contrib/cors v1.7.2 h1:oLDHxdg8W/XDoN/8zamqk/Drgt4oVZDvaV0YmvVICQw= -github.com/gin-contrib/cors v1.7.2/go.mod h1:SUJVARKgQ40dmrzgXEVxj2m7Ig1v1qIboQkPDTQ9t2E= github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= diff --git a/backend/main.go b/backend/main.go index e693d15..a50be7e 100644 --- a/backend/main.go +++ b/backend/main.go @@ -4,20 +4,18 @@ import ( "fmt" "log" "os" - "time" "lphub/api" "lphub/database" _ "lphub/docs" - "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" "github.com/joho/godotenv" ) -// @title Least Portals Database API +// @title Least Portals Hub // @version 1.0 -// @description Backend API endpoints for the Least Portals Database. +// @description Backend API endpoints for Least Portals Hub. // @license.name GNU Affero General Public License, Version 3 // @license.url https://www.gnu.org/licenses/agpl-3.0.html @@ -33,24 +31,22 @@ func main() { gin.SetMode(gin.ReleaseMode) } router := gin.Default() - router.Use(cors.New(cors.Config{ - AllowOrigins: []string{"*"}, - AllowMethods: []string{"GET", "POST", "DELETE", "PUT", "PATCH"}, - AllowHeaders: []string{"Origin"}, - ExposeHeaders: []string{"Content-Length"}, - AllowCredentials: true, - AllowOriginFunc: func(origin string) bool { - return origin == "https://github.com" - }, - MaxAge: 12 * time.Hour, - })) database.ConnectDB() api.InitRoutes(router) - router.Static("/static", "../frontend/build/static") - router.StaticFile("/", "../frontend/build/index.html") - router.NoRoute(func(c *gin.Context) { - c.File("../frontend/build/index.html") - }) - router.MaxMultipartMemory = 500 << 20 // 500 mb limit for demos + // for debugging + // router.Use(cors.New(cors.Config{ + // AllowOrigins: []string{"*"}, + // AllowMethods: []string{"GET", "POST", "DELETE", "PUT", "PATCH"}, + // AllowHeaders: []string{"Origin"}, + // ExposeHeaders: []string{"Content-Length"}, + // AllowCredentials: true, + // MaxAge: 12 * time.Hour, + // })) + // router.Static("/static", "../frontend/build/static") + // router.StaticFile("/", "../frontend/build/index.html") + // router.NoRoute(func(c *gin.Context) { + // c.File("../frontend/build/index.html") + // }) + router.MaxMultipartMemory = 200 << 20 // 200 mb limit for demos router.Run(fmt.Sprintf(":%s", os.Getenv("PORT"))) } -- cgit v1.2.3 From c8028f7a38bdc609f5dde9e56979fb3fe3e60883 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Fri, 18 Oct 2024 15:29:23 +0300 Subject: backend: fix parser map name --- backend/parser/parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backend') diff --git a/backend/parser/parser.go b/backend/parser/parser.go index 4605600..4e4b27a 100644 --- a/backend/parser/parser.go +++ b/backend/parser/parser.go @@ -410,7 +410,7 @@ var mapDict = map[string]int{ "sp_a4_stop_the_box": 52, "sp_a4_laser_catapult": 53, "sp_a4_laser_platform": 54, - "sp_a4_speed_catch": 55, + "sp_a4_speed_tb_catch": 55, "sp_a4_jump_polarity": 56, "sp_a4_finale1": 57, -- cgit v1.2.3 From 05c63d6e3ce6491989a9431d6c4ab1dfae2f5b50 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Fri, 18 Oct 2024 15:37:08 +0300 Subject: docs: add swagger page back --- backend/docs/index.html | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 backend/docs/index.html (limited to 'backend') diff --git a/backend/docs/index.html b/backend/docs/index.html new file mode 100644 index 0000000..8d12274 --- /dev/null +++ b/backend/docs/index.html @@ -0,0 +1,26 @@ + + +
+ + + +