-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
45 lines (34 loc) · 1.17 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
43
44
45
package main
import (
_config "gin-bmg-restful/config"
_handlers "gin-bmg-restful/deliveries/handlers"
"gin-bmg-restful/deliveries/routes"
_heroRepository "gin-bmg-restful/repositories/hero"
_userRepository "gin-bmg-restful/repositories/user"
_authService "gin-bmg-restful/services/auth"
_heroService "gin-bmg-restful/services/hero"
_userService "gin-bmg-restful/services/user"
_utils "gin-bmg-restful/utils"
"github.com/gin-gonic/gin"
)
func main() {
config := _config.New()
db := _utils.NewPostgresConnection(config)
_utils.Migrate(db)
r := gin.Default()
// Repositories
userRepository := _userRepository.NewRepository(db)
heroRepository := _heroRepository.NewRepository()
// Services
authService := _authService.NewService(userRepository)
userService := _userService.NewService(userRepository)
heroService := _heroService.NewService(heroRepository)
// Handler
authHandler := _handlers.NewAuthHandler(authService)
userHandler := _handlers.NewUserHandler(userService)
heroHandler := _handlers.NewHeroHandler(heroService)
// Route
routes.RegisterUserRoute(r, authHandler, userHandler)
routes.RegisterHeroRoute(r, heroHandler)
r.Run(":" + config.App.Port)
}