-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (33 loc) · 1.04 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 (
"log"
"github.com/MountVesuvius/go-gin-postgres-template/controllers"
"github.com/MountVesuvius/go-gin-postgres-template/initialize"
"github.com/MountVesuvius/go-gin-postgres-template/routes"
"github.com/MountVesuvius/go-gin-postgres-template/services"
"github.com/gin-gonic/gin"
"github.com/joho/godotenv"
)
func main() {
// Load Environment Variables
err := godotenv.Load()
if err != nil {
log.Fatal("Error loading environment variables: ", err)
}
// Setup Database
initialize.ConnectToDatabase()
initialize.SyncDatabase()
// Setup Services
jwtService := services.NewJWTService()
userService := services.NewUserService()
// Setup Controllers
userController := controllers.NewUserController(jwtService, userService)
// Setup Router
router := gin.Default()
routes.User(router, userController, jwtService)
routes.Auth(router, jwtService)
routerErr := router.Run()
if routerErr != nil {
log.Fatal("Router has not started", err)
}
}