-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.go
51 lines (39 loc) · 997 Bytes
/
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
package main
import (
"os"
"time"
"github.com/charmbracelet/log"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/helmet"
"github.com/gofiber/fiber/v2/middleware/limiter"
"github.com/gofiber/fiber/v2/middleware/recover"
"github.com/srm-kzilla/Recruitments/api"
"github.com/srm-kzilla/Recruitments/api/utils"
)
func setupRoutes(app *fiber.App) {
app.Get("/", utils.RootFunction)
app.Get("/health", utils.RootFunction)
api.SetupApp(app)
}
func main() {
app := fiber.New()
app.Use(cors.New())
app.Use(helmet.New())
app.Use(recover.New())
app.Use(limiter.New(limiter.Config{
Max: 600,
Expiration: time.Minute,
}))
port := os.Getenv("PORT")
if port == "" {
port = "3000"
}
setupRoutes(app)
log.Infof(`
################################################
🛡️ Server listening on port: %s 🛡️
################################################
`, port)
app.Listen(":" + port)
}