diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2024-09-10 22:13:24 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2024-09-10 22:13:24 +0300 |
| commit | 16165aea34a711027825b3f6512e73a0156f8068 (patch) | |
| tree | 138d92b8b01c41e07a3a2316fd109ddd97e80fa6 /backend/main.go | |
| parent | refactor: update readme (diff) | |
| download | lphub-16165aea34a711027825b3f6512e73a0156f8068.tar.gz lphub-16165aea34a711027825b3f6512e73a0156f8068.tar.bz2 lphub-16165aea34a711027825b3f6512e73a0156f8068.zip | |
refactor: move backend entry, rename module
Diffstat (limited to 'backend/main.go')
| -rw-r--r-- | backend/main.go | 37 |
1 files changed, 37 insertions, 0 deletions
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 @@ | |||
| 1 | package main | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "fmt" | ||
| 5 | "log" | ||
| 6 | "os" | ||
| 7 | |||
| 8 | "lphub/api" | ||
| 9 | "lphub/database" | ||
| 10 | _ "lphub/docs" | ||
| 11 | |||
| 12 | "github.com/gin-gonic/gin" | ||
| 13 | "github.com/joho/godotenv" | ||
| 14 | ) | ||
| 15 | |||
| 16 | // @title Least Portals Database API | ||
| 17 | // @version 1.0 | ||
| 18 | // @description Backend API endpoints for the Least Portals Database. | ||
| 19 | |||
| 20 | // @license.name GNU Affero General Public License, Version 3 | ||
| 21 | // @license.url https://www.gnu.org/licenses/agpl-3.0.html | ||
| 22 | |||
| 23 | // @host lp.ardapektezol.com | ||
| 24 | // @BasePath /api/v1 | ||
| 25 | func main() { | ||
| 26 | err := godotenv.Load() | ||
| 27 | if err != nil { | ||
| 28 | log.Fatal("Error loading .env file") | ||
| 29 | } | ||
| 30 | if os.Getenv("ENV") == "PROD" { | ||
| 31 | gin.SetMode(gin.ReleaseMode) | ||
| 32 | } | ||
| 33 | router := gin.Default() | ||
| 34 | database.ConnectDB() | ||
| 35 | api.InitRoutes(router) | ||
| 36 | router.Run(fmt.Sprintf(":%s", os.Getenv("PORT"))) | ||
| 37 | } | ||