From 96f55dba15bcbba4e6d8f14035ecfd20ebcea8a8 Mon Sep 17 00:00:00 2001 From: Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> Date: Mon, 27 Oct 2025 22:12:31 +0300 Subject: feat/backend: timeline stats endpoint --- backend/main.go | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) (limited to 'backend/main.go') 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() { if err != nil { log.Fatal("Error loading .env file") } + var app *newrelic.Application if os.Getenv("ENV") == "PROD" { gin.SetMode(gin.ReleaseMode) - } - app, err := newrelic.NewApplication( - newrelic.ConfigAppName("lphub"), - newrelic.ConfigLicense(os.Getenv("NEWRELIC_LICENSE_KEY")), - newrelic.ConfigAppLogForwardingEnabled(true), - ) - if err != nil { - log.Fatal("Error instrumenting newrelic") + app, err = newrelic.NewApplication( + newrelic.ConfigAppName("lphub"), + newrelic.ConfigLicense(os.Getenv("NEWRELIC_LICENSE_KEY")), + newrelic.ConfigAppLogForwardingEnabled(true), + ) + if err != nil { + log.Fatal("Error instrumenting newrelic") + } } router := gin.Default() - router.Use(nrgin.Middleware(app)) + if app != nil { + router.Use(nrgin.Middleware(app)) + } + // router.Use(cors.Default()) // ONLY FOR DEV database.ConnectDB() api.InitRoutes(router) - // for debugging - // router.Use(cors.New(cors.Config{ - // AllowOrigins: []string{"*"}, - // AllowMethods: []string{"GET", "POST", "DELETE", "PUT", "PATCH"}, - // AllowHeaders: []string{"Origin"}, - // ExposeHeaders: []string{"Content-Length"}, - // AllowCredentials: true, - // MaxAge: 12 * time.Hour, - // })) - // router.Static("/static", "../frontend/build/static") - // router.StaticFile("/", "../frontend/build/index.html") - // router.NoRoute(func(c *gin.Context) { - // c.File("../frontend/build/index.html") - // }) router.MaxMultipartMemory = 250 << 20 // 250 mb limit for demos router.Run(fmt.Sprintf(":%s", os.Getenv("PORT"))) } -- cgit v1.2.3