-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
42 lines (37 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
42
package main
import (
"github.com/fatemehabsavaran/user-authentication.git/auth/jwt"
"github.com/fatemehabsavaran/user-authentication.git/database/pgsql"
"github.com/fatemehabsavaran/user-authentication.git/io/http"
"github.com/fatemehabsavaran/user-authentication.git/service"
"github.com/spf13/viper"
"strings"
)
var appConfig AppConfig
func init() {
viper.SetConfigFile("config.yml")
viper.AutomaticEnv()
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
if err := viper.ReadInConfig(); err != nil {
panic(err)
}
if err := viper.Unmarshal(&appConfig); err != nil {
panic(err)
}
}
func main() {
psqlService, err := pgsql.NewPgsqlFromConfig(appConfig.DbConfig)
if err != nil {
panic(err)
}
jwtService := jwt.NewFromConfig(appConfig.JWtConfig)
userService := service.UserService{
Db: psqlService,
Auth: jwtService,
}
userController := http.NewUserController(appConfig.GinConfig, userService)
userController.RegisterRoutes()
if err := userController.Start(); err != nil {
panic(err)
}
}