-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (32 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
package main
import (
// "fmt"
"fmt"
"github.com/fuadsuleyman/go-auth/database"
"github.com/fuadsuleyman/go-auth/routes"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/sirupsen/logrus"
"github.com/spf13/viper"
)
func main() {
if err := initConfig(); err != nil {
logrus.Fatalf("error initializing configs: %s", err.Error())
}
database.Connect()
app := fiber.New()
app.Use(cors.New(cors.Config{
AllowCredentials: true,
}))
app.Use(
logger.New(), // add Logger middleware
)
routes.Setup(app)
app.Listen(fmt.Sprintf(":%s", viper.GetString("port")))
}
func initConfig() error {
viper.AddConfigPath("configs")
viper.SetConfigName("config")
return viper.ReadInConfig()
}