diff options
| -rw-r--r-- | backend/go.mod | 1 | ||||
| -rw-r--r-- | backend/go.sum | 2 | ||||
| -rw-r--r-- | backend/main.go | 38 |
3 files changed, 17 insertions, 24 deletions
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 | ||
| 10 | require ( | 10 | require ( |
| 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 | |||
| 31 | github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= | 31 | github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= |
| 32 | github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4= | 32 | github.com/gabriel-vasile/mimetype v1.4.5 h1:J7wGKdGu33ocBOhGy0z653k/lFKLFDPJMG8Gql0kxn4= |
| 33 | github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4= | 33 | github.com/gabriel-vasile/mimetype v1.4.5/go.mod h1:ibHel+/kbxn9x2407k1izTA1S81ku1z/DlgOW2QE0M4= |
| 34 | github.com/gin-contrib/cors v1.7.2 h1:oLDHxdg8W/XDoN/8zamqk/Drgt4oVZDvaV0YmvVICQw= | ||
| 35 | github.com/gin-contrib/cors v1.7.2/go.mod h1:SUJVARKgQ40dmrzgXEVxj2m7Ig1v1qIboQkPDTQ9t2E= | ||
| 36 | github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= | 34 | github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= |
| 37 | github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= | 35 | github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= |
| 38 | github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= | 36 | 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 ( | |||
| 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,24 +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"}, |
| 54 | router.MaxMultipartMemory = 500 << 20 // 500 mb limit for demos | 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 | ||
| 55 | router.Run(fmt.Sprintf(":%s", os.Getenv("PORT"))) | 51 | router.Run(fmt.Sprintf(":%s", os.Getenv("PORT"))) |
| 56 | } | 52 | } |