forked from BrondoL/e-wallet-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
52 lines (41 loc) · 2.21 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
package main
import (
"fmt"
"os"
"git.garena.com/sea-labs-id/batch-02/aulia-nabil/assignment-05-golang-backend/config"
"git.garena.com/sea-labs-id/batch-02/aulia-nabil/assignment-05-golang-backend/internal/handler"
"git.garena.com/sea-labs-id/batch-02/aulia-nabil/assignment-05-golang-backend/internal/repository"
"git.garena.com/sea-labs-id/batch-02/aulia-nabil/assignment-05-golang-backend/internal/route"
"git.garena.com/sea-labs-id/batch-02/aulia-nabil/assignment-05-golang-backend/internal/service"
"github.com/gin-gonic/gin"
)
func main() {
db := config.GetConn()
userRepository := repository.NewUserRepository(&repository.URConfig{DB: db})
walletRepository := repository.NewWalletRepository(&repository.WRConfig{DB: db})
passwordResetRepository := repository.NewPasswordResetRepository(&repository.PRConfig{DB: db})
sourceOfFundRepository := repository.NewSourceOfFundRepository(&repository.SRConfig{DB: db})
transactionRepository := repository.NewTransactionRepository(&repository.TRConfig{DB: db})
userService := service.NewUserService(&service.USConfig{UserRepository: userRepository})
authService := service.NewAuthService(&service.ASConfig{UserRepository: userRepository, PasswordResetRepository: passwordResetRepository})
walletService := service.NewWalletService(&service.WSConfig{UserRepository: userRepository, WalletRepository: walletRepository})
transactionService := service.NewTransactionService(&service.TSConfig{TransactionRepository: transactionRepository, SourceOfFundRepository: sourceOfFundRepository, WalletRepository: walletRepository})
jwtService := service.NewJWTService(&service.JWTSConfig{})
h := handler.NewHandler(&handler.HandlerConfig{
UserService: userService,
AuthService: authService,
WalletService: walletService,
TransactionService: transactionService,
JWTService: jwtService,
})
routes := route.NewRouter(&route.RouterConfig{UserService: userService, JWTService: jwtService})
router := gin.Default()
router.Static("/docs", "./pkg/swaggerui")
router.NoRoute(h.NoRoute)
version := os.Getenv("API_VERSION")
api := router.Group(fmt.Sprintf("/api/%s", version))
routes.Auth(api, h)
routes.User(api, h)
routes.Transaction(api, h)
router.Run(":8000")
}