aboutsummaryrefslogtreecommitdiff
path: root/backend/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'backend/main.go')
-rw-r--r--backend/main.go36
1 files changed, 13 insertions, 23 deletions
diff --git a/backend/main.go b/backend/main.go
index e422359..2147be8 100644
--- a/backend/main.go
+++ b/backend/main.go
@@ -29,35 +29,25 @@ func main() {
29 if err != nil { 29 if err != nil {
30 log.Fatal("Error loading .env file") 30 log.Fatal("Error loading .env file")
31 } 31 }
32 var app *newrelic.Application
32 if os.Getenv("ENV") == "PROD" { 33 if os.Getenv("ENV") == "PROD" {
33 gin.SetMode(gin.ReleaseMode) 34 gin.SetMode(gin.ReleaseMode)
34 } 35 app, err = newrelic.NewApplication(
35 app, err := newrelic.NewApplication( 36 newrelic.ConfigAppName("lphub"),
36 newrelic.ConfigAppName("lphub"), 37 newrelic.ConfigLicense(os.Getenv("NEWRELIC_LICENSE_KEY")),
37 newrelic.ConfigLicense(os.Getenv("NEWRELIC_LICENSE_KEY")), 38 newrelic.ConfigAppLogForwardingEnabled(true),
38 newrelic.ConfigAppLogForwardingEnabled(true), 39 )
39 ) 40 if err != nil {
40 if err != nil { 41 log.Fatal("Error instrumenting newrelic")
41 log.Fatal("Error instrumenting newrelic") 42 }
42 } 43 }
43 router := gin.Default() 44 router := gin.Default()
44 router.Use(nrgin.Middleware(app)) 45 if app != nil {
46 router.Use(nrgin.Middleware(app))
47 }
48 // router.Use(cors.Default()) // ONLY FOR DEV
45 database.ConnectDB() 49 database.ConnectDB()
46 api.InitRoutes(router) 50 api.InitRoutes(router)
47 // for debugging
48 // router.Use(cors.New(cors.Config{
49 // AllowOrigins: []string{"*"},
50 // AllowMethods: []string{"GET", "POST", "DELETE", "PUT", "PATCH"},
51 // AllowHeaders: []string{"Origin"},
52 // ExposeHeaders: []string{"Content-Length"},
53 // AllowCredentials: true,
54 // MaxAge: 12 * time.Hour,
55 // }))
56 // router.Static("/static", "../frontend/build/static")
57 // router.StaticFile("/", "../frontend/build/index.html")
58 // router.NoRoute(func(c *gin.Context) {
59 // c.File("../frontend/build/index.html")
60 // })
61 router.MaxMultipartMemory = 250 << 20 // 250 mb limit for demos 51 router.MaxMultipartMemory = 250 << 20 // 250 mb limit for demos
62 router.Run(fmt.Sprintf(":%s", os.Getenv("PORT"))) 52 router.Run(fmt.Sprintf(":%s", os.Getenv("PORT")))
63} 53}