From 16165aea34a711027825b3f6512e73a0156f8068 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Tue, 10 Sep 2024 22:13:24 +0300 Subject: refactor: move backend entry, rename module --- backend/main.go | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 backend/main.go (limited to 'backend/main.go') diff --git a/backend/main.go b/backend/main.go new file mode 100644 index 0000000..202c607 --- /dev/null +++ b/backend/main.go @@ -0,0 +1,37 @@ +package main + +import ( + "fmt" + "log" + "os" + + "lphub/api" + "lphub/database" + _ "lphub/docs" + + "github.com/gin-gonic/gin" + "github.com/joho/godotenv" +) + +// @title Least Portals Database API +// @version 1.0 +// @description Backend API endpoints for the Least Portals Database. + +// @license.name GNU Affero General Public License, Version 3 +// @license.url https://www.gnu.org/licenses/agpl-3.0.html + +// @host lp.ardapektezol.com +// @BasePath /api/v1 +func main() { + err := godotenv.Load() + if err != nil { + log.Fatal("Error loading .env file") + } + if os.Getenv("ENV") == "PROD" { + gin.SetMode(gin.ReleaseMode) + } + router := gin.Default() + database.ConnectDB() + api.InitRoutes(router) + router.Run(fmt.Sprintf(":%s", os.Getenv("PORT"))) +} -- cgit v1.2.3