-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (34 loc) · 1.01 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
package main
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/compress"
"github.com/joho/godotenv"
log "github.com/sirupsen/logrus"
"github.com/tamnk74/todolist-mysql-go/config"
"github.com/tamnk74/todolist-mysql-go/database"
"github.com/tamnk74/todolist-mysql-go/middlewares"
"github.com/tamnk74/todolist-mysql-go/router"
"github.com/tamnk74/todolist-mysql-go/schedulers"
"github.com/tamnk74/todolist-mysql-go/utils/queue"
"github.com/tamnk74/todolist-mysql-go/utils/redis"
)
func main() {
err := godotenv.Load(".env")
if err != nil {
log.Fatal("Error loading .env file")
}
err = database.Connect()
if err != nil {
panic("Failed to connect database")
}
app := fiber.New(middlewares.HandleApiError())
app.Use(compress.New(compress.Config{
Level: compress.LevelBestSpeed,
}))
router.Init(app)
schedulers.Init()
redis.Init()
queue.Init()
log.Info("Starting API server at port " + config.PORT)
app.Listen(":" + config.PORT)
}