-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
50 lines (39 loc) · 805 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
package main
import (
"fmt"
"log"
"strconv"
"github.com/eskylake/go-todo/config"
"github.com/eskylake/go-todo/database"
"github.com/eskylake/go-todo/routers"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
)
var (
conf config.Config
err error
)
func dd(arg ...any) {
log.Fatalln(arg...)
panic("Die")
}
func init() {
conf, err = config.LoadConfig(".")
if err != nil {
dd("Failed to load environment variables! \n", err.Error())
}
database.ConnectDB(&conf)
}
func main() {
app := fiber.New()
micro := fiber.New()
app.Mount("/api", micro)
app.Use(logger.New())
app.Use(routers.Cors())
routers.SetupRoutes(micro)
port, err := strconv.Atoi(conf.APIPort)
if err != nil {
dd(err.Error())
}
log.Fatal(app.Listen(fmt.Sprintf(":%d", port)))
}