This repository has been archived by the owner on Mar 3, 2024. It is now read-only.
generated from CodeChefVIT/template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
61 lines (54 loc) · 1.53 KB
/
main.go
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"devsoc23-backend/database"
helper "devsoc23-backend/helper"
"devsoc23-backend/routes"
"log"
"os"
"time"
"github.com/getsentry/sentry-go"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/limiter"
"github.com/gofiber/fiber/v2/middleware/logger"
)
func main() {
helper.LoadEnv()
err := sentry.Init(sentry.ClientOptions{
Dsn: os.Getenv("SENTRY_DSN"),
// Set TracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production,
TracesSampleRate: 1.0,
})
if err != nil {
log.Fatalf("sentry.Init: %s", err)
}
app := fiber.New()
app.Use(cors.New(cors.Config{
AllowHeaders: "Origin,Content-Type,Accept,Content-Length,Accept-Language,Accept-Encoding,Connection,Access-Control-Allow-Origin",
AllowOrigins: "*",
AllowCredentials: true,
AllowMethods: "GET,POST,HEAD,PUT,DELETE,PATCH,OPTIONS",
}))
// Api rate limiter
app.Use(limiter.New(limiter.Config{
Max: 500,
Expiration: 30 * time.Second,
}))
app.Use(logger.New())
handler := database.NewDatabase()
app.Get("/ping", func(c *fiber.Ctx) error {
return c.Status(fiber.StatusOK).JSON(fiber.Map{
"message": "pong",
})
})
routes.UserRoutes(app, &handler)
routes.TeamRoutes(app, &handler)
routes.ProjectRoutes(app, &handler)
routes.TimelineRoutes(app, &handler)
err = app.Listen(":8000")
if err != nil {
panic(err)
}
}