-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
88 lines (69 loc) · 3 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package main
import (
"capstone/configs"
"fmt"
"log"
"net/http"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
_authHandler "capstone/delivery/handler/auth"
_paymentHandler "capstone/delivery/handler/payment"
_authRepository "capstone/repository/auth"
_paymentRepo "capstone/repository/transaction"
_authUseCase "capstone/usecase/auth"
_paymentURLMidtrans "capstone/usecase/payment"
_paymentUseCase "capstone/usecase/transaction"
_userHandler "capstone/delivery/handler/user"
_routes "capstone/delivery/routes"
_userRepository "capstone/repository/user"
_userUseCase "capstone/usecase/user"
_categoryHandler "capstone/delivery/handler/category"
_categoryRepository "capstone/repository/category"
_categoryUseCase "capstone/usecase/category"
_facilityHandler "capstone/delivery/handler/facility"
_facilityRepository "capstone/repository/facility"
_facilityUseCase "capstone/usecase/facility"
_venueHandler "capstone/delivery/handler/venue"
_venueRepository "capstone/repository/venue"
_venueUseCase "capstone/usecase/venue"
_middleware "capstone/delivery/middlewares"
_utils "capstone/utils"
)
func main() {
config := configs.GetConfig()
db := _utils.InitDB(config)
userRepo := _userRepository.NewUserRepository(db)
userUseCase := _userUseCase.NewUserUseCase(userRepo)
userHandler := _userHandler.NewUserHandler(userUseCase)
authRepo := _authRepository.NewAuthRepository(db)
authUseCase := _authUseCase.NewAuthUseCase(authRepo)
authHandler := _authHandler.NewAuthHandler(authUseCase)
categoryRepo := _categoryRepository.NewCategoryRepository(db)
categoryUseCase := _categoryUseCase.NewCategoryUseCase(categoryRepo)
categoryHandler := _categoryHandler.NewCategoryHandler(categoryUseCase)
facilityRepo := _facilityRepository.NewFacilityRepository(db)
facilityUseCase := _facilityUseCase.NewFacilityUseCase(facilityRepo)
facilityHandler := _facilityHandler.NewFacilityHandler(facilityUseCase)
venueRepo := _venueRepository.NewVenueRepository(db)
venueUseCase := _venueUseCase.NewVenueUseCase(venueRepo)
venueHandler := _venueHandler.NewVenueHandler(venueUseCase)
paymentUrlMidtransService := _paymentURLMidtrans.NewService()
paymentRepo := _paymentRepo.NewPaymentRepository(db)
paymentUseCase := _paymentUseCase.NewPaymentUseCase(paymentRepo, paymentUrlMidtransService)
paymentHandler := _paymentHandler.NewPaymentHandler(paymentUseCase, userUseCase)
e := echo.New()
e.Use(middleware.CORS())
e.Pre(middleware.RemoveTrailingSlash())
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
AllowOrigins: []string{"*"},
AllowMethods: []string{http.MethodGet, http.MethodPut, http.MethodPost, http.MethodDelete},
}))
e.Use(_middleware.CustomLogger())
_routes.RegisterUserPath(e, userHandler)
_routes.RegisterAuthPath(e, authHandler)
_routes.RegisterCategoryPath(e, categoryHandler)
_routes.RegisterFacilityPath(e, facilityHandler)
_routes.RegisterVenuePath(e, venueHandler)
_routes.PaymentArenaPath(e, paymentHandler)
log.Fatal(e.Start(fmt.Sprintf(":%v", config.Port)))
}