-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (37 loc) · 1.11 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
package main
import (
"github.com/kakwa/wows-whaling-simulator/api"
"github.com/kakwa/wows-whaling-simulator/config"
"github.com/kakwa/wows-whaling-simulator/lootbox"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func main() {
e := echo.New()
e.Use(middleware.Logger())
// TODO properly set log level
e.HideBanner = true
cfg, err := config.ParseConfig("./config/example.yml")
if err != nil {
e.Logger.Fatalf("failed to parse configuration: %w", err)
}
logLevel, err := cfg.ConvertLogLevel()
if err != nil {
e.Logger.Fatalf("failed to parse LogLevel: %s", err)
}
e.Logger.SetLevel(logLevel)
lootbox.InitStatsWorkers()
apiv1, err := api.NewAPI(e, cfg)
if err != nil {
e.Logger.Fatalf("failed to init API: %s", err)
}
apiv1.RegisterRoutes()
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: []string{"http://localhost:8080", "http://localhost:3000"},
AllowHeaders: []string{echo.HeaderOrigin, echo.HeaderContentType, echo.HeaderAccept},
}))
e.Use(middleware.GzipWithConfig(middleware.GzipConfig{
Level: 5,
}))
e.Logger.Fatal(e.Start(cfg.Listen))
}