diff options
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 11 |
1 files changed, 9 insertions, 2 deletions
| @@ -1,17 +1,24 @@ | |||
| 1 | package main | 1 | package main |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "log" | ||
| 5 | "os" | ||
| 6 | |||
| 4 | "github.com/gin-gonic/contrib/static" | 7 | "github.com/gin-gonic/contrib/static" |
| 5 | "github.com/gin-gonic/gin" | 8 | "github.com/gin-gonic/gin" |
| 6 | "github.com/pektezol/leastportals/backend/controllers" | 9 | "github.com/joho/godotenv" |
| 7 | "github.com/pektezol/leastportals/backend/database" | 10 | "github.com/pektezol/leastportals/backend/database" |
| 8 | "github.com/pektezol/leastportals/backend/routes" | 11 | "github.com/pektezol/leastportals/backend/routes" |
| 9 | ) | 12 | ) |
| 10 | 13 | ||
| 11 | func main() { | 14 | func main() { |
| 12 | if controllers.GetEnvKey("ENV") == "PROD" { | 15 | if os.Getenv("ENV") == "PROD" { |
| 13 | gin.SetMode(gin.ReleaseMode) | 16 | gin.SetMode(gin.ReleaseMode) |
| 14 | } | 17 | } |
| 18 | err := godotenv.Load() | ||
| 19 | if err != nil { | ||
| 20 | log.Fatal("Error loading .env file") | ||
| 21 | } | ||
| 15 | router := gin.Default() | 22 | router := gin.Default() |
| 16 | database.ConnectDB() | 23 | database.ConnectDB() |
| 17 | router.Use(static.Serve("/", static.LocalFile("./frontend/dist", true))) | 24 | router.Use(static.Serve("/", static.LocalFile("./frontend/dist", true))) |