blob: b6564b67400966c8c7e6d06f1a3d12a829fb7b7c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
package main
import (
"fmt"
"log"
"os"
"github.com/gin-gonic/contrib/cors"
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
"github.com/pektezol/leastportals/backend/database"
"github.com/pektezol/leastportals/backend/routes"
_ "github.com/pektezol/leastportals/docs"
)
// @title Least Portals Database API
// @version 1.0
// @description Backend API endpoints for the Least Portals Database.
// @license.name GNU General Public License, Version 2
// @license.url https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
// @host lp.ardapektezol.com/api
// @BasePath /v1
func main() {
if os.Getenv("ENV") == "PROD" {
gin.SetMode(gin.ReleaseMode)
}
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading .env file")
}
router := gin.Default()
config := cors.DefaultConfig()
config.AllowAllOrigins = true
router.Use(cors.New(config))
database.ConnectDB()
// For frontend static serving - only for local debug
// router.Use(static.Serve("/", static.LocalFile("./frontend/build", true)))
routes.InitRoutes(router)
router.Run(fmt.Sprintf(":%s", os.Getenv("PORT")))
}
|