-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.go
42 lines (31 loc) · 814 Bytes
/
setup.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 (
"log"
"os"
"github.com/ffardo/user-crud/controllers"
"github.com/ffardo/user-crud/infrastructures"
"github.com/ffardo/user-crud/repositories"
"github.com/ffardo/user-crud/routes"
"github.com/ffardo/user-crud/services"
"github.com/gin-gonic/gin"
)
func setup() *gin.Engine {
mongoUri := os.Getenv("MONGO_URI")
mongoUsername := os.Getenv("MONGO_USERNAME")
mongoPassword := os.Getenv("MONGO_PASSWORD")
apiKey := os.Getenv("API_KEY")
client, err := infrastructures.CreateMongoClient(mongoUri, mongoUsername, mongoPassword)
if err != nil {
log.Fatal(err)
}
ur := repositories.UserRepository{
Client: client,
}
ur.Init()
uc := controllers.UserController{
UserService: services.UserService{
UserRepository: ur,
},
}
return routes.InitRouter(&uc, apiKey)
}