-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
53 lines (45 loc) · 1.2 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
package main
import (
"log"
"oblivion/draft/routes"
"oblivion/draft/utils"
"os"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/monitor"
"github.com/gofiber/fiber/v2/middleware/recover"
)
func serve() {
app := fiber.New(fiber.Config{
// Override default error handler
ErrorHandler: func(c *fiber.Ctx, err error) error {
log.Println(err)
code := fiber.StatusInternalServerError
c.Set(fiber.HeaderContentType, fiber.MIMETextPlainCharsetUTF8)
return c.Status(code).SendString("Internal Server Error")
},
})
app.Get("/metrics", monitor.New())
app.Use(recover.New())
waitLcu := os.Getenv("WAIT_LCU")
routes.StaticRoutes(app)
routes.AdminRoutes(app)
if waitLcu == "true" || waitLcu == "1" || waitLcu == "TRUE" {
routes.LcuRoutes(app)
}
routes.RiotApiRoutes(app)
routes.SupabaseRoutes(app)
// start the websocket listener for the game in a goroutine
go utils.ConnectAndLogWebSocket("ws://localhost:49122", "game.log")
app.Listen(":80")
}
func main() {
utils.ConfigLogger()
if len(os.Args) > 1 && os.Args[1] == "setup" {
utils.Setup()
} else if len(os.Args) > 1 && os.Args[1] == "update" {
utils.UpdateOverlay()
} else {
utils.CheckSetup()
serve()
}
}