aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfboy248 <georgejvindkarlsen@gmail.com>2024-10-18 17:16:26 +0200
committerWolfboy248 <georgejvindkarlsen@gmail.com>2024-10-18 17:16:26 +0200
commit66effd60efee7c3429f1f71118483f3b02237790 (patch)
treee0b9c407b0c66d62f385cca26a01529d055f28f7
parentrefactor: delete run on profile (diff)
parentdocs: add swagger page back (diff)
downloadlphub-66effd60efee7c3429f1f71118483f3b02237790.tar.gz
lphub-66effd60efee7c3429f1f71118483f3b02237790.tar.bz2
lphub-66effd60efee7c3429f1f71118483f3b02237790.zip
Merge branch 'typescript' of https://github.com/pektezol/LeastPortalsHub into typescript
refactor: IDFK MERGE SOMETHING
-rw-r--r--backend/docs/index.html26
-rw-r--r--backend/go.mod1
-rw-r--r--backend/go.sum2
-rw-r--r--backend/handlers/user.go2
-rw-r--r--backend/main.go37
-rw-r--r--backend/parser/parser.go2
-rw-r--r--frontend/public/index.html2
-rw-r--r--rankings/main.go25
8 files changed, 60 insertions, 37 deletions
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 @@
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="utf-8" />
5 <meta name="viewport" content="width=device-width, initial-scale=1" />
6 <meta
7 name="description"
8 content="SwaggerIU"
9 />
10 <title>SwaggerUI</title>
11 <link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@4.4.1/swagger-ui.css" />
12</head>
13<body>
14 <div id="swagger-ui"></div>
15 <script src="https://unpkg.com/swagger-ui-dist@4.4.1/swagger-ui-bundle.js" crossorigin></script>
16 <script src="https://unpkg.com/swagger-ui-dist@4.4.1/swagger-ui-standalone-preset.js" crossorigin></script>
17 <script>
18 window.onload = () => {
19 window.ui = SwaggerUIBundle({
20 url: 'https://lp.ardapektezol.com/swagger.json',
21 dom_id: '#swagger-ui',
22 });
23 };
24 </script>
25</body>
26</html> \ No newline at end of file
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 (
8) 8)
9 9
10require ( 10require (
11 github.com/gin-contrib/cors v1.7.2
12 github.com/golang-jwt/jwt/v4 v4.5.0 11 github.com/golang-jwt/jwt/v4 v4.5.0
13 github.com/google/uuid v1.6.0 12 github.com/google/uuid v1.6.0
14 github.com/pektezol/steam_go v1.1.2 13 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
31github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= 31github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
32github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4= 32github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4=
33github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4= 33github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4=
34github.com/gin-contrib/cors v1.7.2 h1:oLDHxdg8W/XDoN/8zamqk/Drgt4oVZDvaV0YmvVICQw=
35github.com/gin-contrib/cors v1.7.2/go.mod h1:SUJVARKgQ40dmrzgXEVxj2m7Ig1v1qIboQkPDTQ9t2E=
36github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= 34github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4=
37github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= 35github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk=
38github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= 36github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
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) {
294 } 294 }
295 records := []ProfileRecords{} 295 records := []ProfileRecords{}
296 // Get singleplayer records 296 // Get singleplayer records
297 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 297 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
298 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` 298 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`
299 rows, err = database.DB.Query(sql, user.(models.User).SteamID) 299 rows, err = database.DB.Query(sql, user.(models.User).SteamID)
300 if err != nil { 300 if err != nil {
diff --git a/backend/main.go b/backend/main.go
index 306823c..a50be7e 100644
--- a/backend/main.go
+++ b/backend/main.go
@@ -4,20 +4,18 @@ import (
4 "fmt" 4 "fmt"
5 "log" 5 "log"
6 "os" 6 "os"
7 "time"
8 7
9 "lphub/api" 8 "lphub/api"
10 "lphub/database" 9 "lphub/database"
11 _ "lphub/docs" 10 _ "lphub/docs"
12 11
13 "github.com/gin-contrib/cors"
14 "github.com/gin-gonic/gin" 12 "github.com/gin-gonic/gin"
15 "github.com/joho/godotenv" 13 "github.com/joho/godotenv"
16) 14)
17 15
18// @title Least Portals Database API 16// @title Least Portals Hub
19// @version 1.0 17// @version 1.0
20// @description Backend API endpoints for the Least Portals Database. 18// @description Backend API endpoints for Least Portals Hub.
21 19
22// @license.name GNU Affero General Public License, Version 3 20// @license.name GNU Affero General Public License, Version 3
23// @license.url https://www.gnu.org/licenses/agpl-3.0.html 21// @license.url https://www.gnu.org/licenses/agpl-3.0.html
@@ -33,23 +31,22 @@ func main() {
33 gin.SetMode(gin.ReleaseMode) 31 gin.SetMode(gin.ReleaseMode)
34 } 32 }
35 router := gin.Default() 33 router := gin.Default()
36 router.Use(cors.New(cors.Config{
37 AllowOrigins: []string{"*"},
38 AllowMethods: []string{"GET", "POST", "DELETE", "PUT", "PATCH"},
39 AllowHeaders: []string{"Origin"},
40 ExposeHeaders: []string{"Content-Length"},
41 AllowCredentials: true,
42 AllowOriginFunc: func(origin string) bool {
43 return origin == "https://github.com"
44 },
45 MaxAge: 12 * time.Hour,
46 }))
47 database.ConnectDB() 34 database.ConnectDB()
48 api.InitRoutes(router) 35 api.InitRoutes(router)
49 router.Static("/static", "../frontend/build/static") 36 // for debugging
50 router.StaticFile("/", "../frontend/build/index.html") 37 // router.Use(cors.New(cors.Config{
51 router.NoRoute(func(c *gin.Context) { 38 // AllowOrigins: []string{"*"},
52 c.File("../frontend/build/index.html") 39 // AllowMethods: []string{"GET", "POST", "DELETE", "PUT", "PATCH"},
53 }) 40 // AllowHeaders: []string{"Origin"},
41 // ExposeHeaders: []string{"Content-Length"},
42 // AllowCredentials: true,
43 // MaxAge: 12 * time.Hour,
44 // }))
45 // router.Static("/static", "../frontend/build/static")
46 // router.StaticFile("/", "../frontend/build/index.html")
47 // router.NoRoute(func(c *gin.Context) {
48 // c.File("../frontend/build/index.html")
49 // })
50 router.MaxMultipartMemory = 200 << 20 // 200 mb limit for demos
54 router.Run(fmt.Sprintf(":%s", os.Getenv("PORT"))) 51 router.Run(fmt.Sprintf(":%s", os.Getenv("PORT")))
55} 52}
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{
410 "sp_a4_stop_the_box": 52, 410 "sp_a4_stop_the_box": 52,
411 "sp_a4_laser_catapult": 53, 411 "sp_a4_laser_catapult": 53,
412 "sp_a4_laser_platform": 54, 412 "sp_a4_laser_platform": 54,
413 "sp_a4_speed_catch": 55, 413 "sp_a4_speed_tb_catch": 55,
414 "sp_a4_jump_polarity": 56, 414 "sp_a4_jump_polarity": 56,
415 415
416 "sp_a4_finale1": 57, 416 "sp_a4_finale1": 57,
diff --git a/frontend/public/index.html b/frontend/public/index.html
index 0bd6da2..46a123a 100644
--- a/frontend/public/index.html
+++ b/frontend/public/index.html
@@ -7,7 +7,7 @@
7 <meta name="theme-color" content="#000000" /> 7 <meta name="theme-color" content="#000000" />
8 <meta 8 <meta
9 name="description" 9 name="description"
10 content="Web site created using create-react-app" 10 content="Least Portals Hub"
11 /> 11 />
12 <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> 12 <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
13 <!-- 13 <!--
diff --git a/rankings/main.go b/rankings/main.go
index 70a25e9..dfafb0c 100644
--- a/rankings/main.go
+++ b/rankings/main.go
@@ -2,8 +2,12 @@ package main
2 2
3import ( 3import (
4 "log" 4 "log"
5 "os"
6 "os/signal"
7 "syscall"
5 8
6 "github.com/joho/godotenv" 9 "github.com/joho/godotenv"
10 "github.com/robfig/cron/v3"
7) 11)
8 12
9func main() { 13func main() {
@@ -11,17 +15,16 @@ func main() {
11 if err != nil { 15 if err != nil {
12 log.Fatalln("Error loading .env file:", err.Error()) 16 log.Fatalln("Error loading .env file:", err.Error())
13 } 17 }
14 run() 18 c := cron.New()
15 // c := cron.New() 19 _, err = c.AddFunc("0 0 * * *", run)
16 // _, err = c.AddFunc("0 0 * * *", run) 20 if err != nil {
17 // if err != nil { 21 log.Fatalln("Error scheduling daily reminder:", err.Error())
18 // log.Fatalln("Error scheduling daily reminder:", err.Error()) 22 }
19 // } 23 c.Start()
20 // c.Start() 24 log.Println("ready for jobs")
21 // log.Println("ready for jobs") 25 sc := make(chan os.Signal, 1)
22 // sc := make(chan os.Signal, 1) 26 signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
23 // signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) 27 <-sc
24 // <-sc
25} 28}
26 29
27func run() { 30func run() {