-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
77 lines (59 loc) · 2.27 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
package main
import (
"github.com/SlyCreator/biko-Ego/config"
"github.com/gin-gonic/gin"
"github.com/SlyCreator/biko-Ego/controllers"
"github.com/SlyCreator/biko-Ego/repository"
"github.com/SlyCreator/biko-Ego/services"
"gorm.io/gorm"
)
var (
db *gorm.DB = config.OpenDatabaseConnection()
userRepository repository.UserRepository = repository.NewUserRepository(db)
authService services.AuthService = services.NewAuthService(userRepository)
jwtService services.JWTService = services.NewJWTService()
authController controllers.AuthControlller = controllers.NewAuthController(authService, jwtService)
)
func main() {
r := gin.Default()
authRoute := r.Group("api/user")
{
authRoute.POST("/register",authController.Register)
authRoute.POST("/login",authController.Login)
authRoute.POST("/reset_password",authController.ForgetPassword)
}
userRoute := r.Group("api/user")
{
userRoute.GET("/",userController.FetchProfile)
userRoute.PATCH("/",userController.UpdateProfile)
userRoute.PATCH("/",userController.DeleteAccount)
userRoute.POST("/next_of_kins",userController.UpdateNextOfKins)
userRoute.POST("/send_complain",userController.SendReport)
transactionRoute := r.Group("account")
{
transactionRoute.GET("/",userController.FetchAccount)
transactionRoute.POST("/add_payment_method",userController.AddCard)
transactionRoute.DELETE("/delete_payment_method",userController.RemoveCard)
transactionRoute.POST("/fund_acct",userController.FundAccount)
transactionRoute.POST("/withdraw_fund",userController.WithdrawFromAccount)
}
transactionRoute := r.Group("investor")
{
transactionRoute.GET("/",userController.FetchAccount)
transactionRoute.POST("/add_payment_method",userController.AddCard)
transactionRoute.DELETE("/delete_payment_method",userController.RemoveCard)
transactionRoute.POST("/fund_acct",userController.FundAccount)
transactionRoute.POST("/withdraw_fund",userController.WithdrawFromAccount)
}
}
investorRoute := r.Group("api/investor")
{
investorRoute.PATCH("/",userController.Login)
}
borrowerRoute := r.Group("api/borrower")
{
borrowerRoute.PATCH("/",borrowerController.Login)
}
r.Run(":2020")
}
//Route ======> Repository use (Entity) ====> Service(DTO) ====> Controller(helper) ====>