-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
52 lines (43 loc) · 2 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 (
"github.com/gofiber/fiber/v2"
"shellrean.id/belajar-auth/dto"
"shellrean.id/belajar-auth/internal/api"
"shellrean.id/belajar-auth/internal/component"
"shellrean.id/belajar-auth/internal/config"
"shellrean.id/belajar-auth/internal/middleware"
"shellrean.id/belajar-auth/internal/repository"
"shellrean.id/belajar-auth/internal/service"
"shellrean.id/belajar-auth/internal/sse"
)
func main() {
cnf := config.Get()
dbConnection := component.GetDatabaseConnection(cnf)
cacheConnection := repository.NewRedisClient(cnf)
hub := &dto.Hub{
NotificationChannel: map[int64]chan dto.NotificationData{},
}
userRepository := repository.NewUser(dbConnection)
accountRepository := repository.NewAccount(dbConnection)
transactionRepository := repository.NewTransaction(dbConnection)
notificationRepository := repository.NewNotification(dbConnection)
templateRepository := repository.NewTemplate(dbConnection)
topUpRepository := repository.NewTopUp(dbConnection)
factorRepository := repository.NewFactor(dbConnection)
emailService := service.NewEmail(cnf)
userService := service.NewUser(userRepository, cacheConnection, emailService)
notificationService := service.NewNotification(notificationRepository, templateRepository, hub)
transactionService := service.NewTransaction(accountRepository, transactionRepository, cacheConnection, notificationService)
midtransService := service.NewMidtrans(cnf)
topUpService := service.NewTopUp(notificationService, midtransService, topUpRepository, accountRepository, transactionRepository)
factorService := service.NewFactor(factorRepository)
authMid := middleware.Authenticate(userService)
app := fiber.New()
api.NewAuth(app, userService, authMid)
api.NewTransfer(app, authMid, transactionService, factorService)
api.NewNotification(app, authMid, notificationService)
api.NewTopUp(app, authMid, topUpService)
api.NewMidtrans(app, midtransService, topUpService)
sse.NewNotification(app, authMid, hub)
_ = app.Listen(cnf.Server.Host + ":" + cnf.Server.Port)
}