-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
38 lines (34 loc) · 1.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
package main
import (
"fmt"
"github.com/didiyudha/transaction-accross-pkg/config"
"github.com/didiyudha/transaction-accross-pkg/domain/profile/handler"
"github.com/didiyudha/transaction-accross-pkg/domain/profile/repository"
"github.com/didiyudha/transaction-accross-pkg/domain/profile/usecase"
userrepo "github.com/didiyudha/transaction-accross-pkg/domain/user/repository"
"github.com/didiyudha/transaction-accross-pkg/internal/platform/postgres"
"github.com/labstack/echo/v4"
"github.com/sirupsen/logrus"
)
func main() {
if err := config.Load(); err != nil {
logrus.Fatal(err)
}
dbWrite, err := postgres.Open(config.Cfg.DB)
if err != nil {
logrus.Fatal(err)
}
dbRead, err := postgres.Open(config.Cfg.DB)
if err != nil {
logrus.Fatal(err)
}
userRepository := userrepo.NewUserRepository(dbWrite, dbRead)
profileRepository := repository.NewProfileRepository(dbWrite, dbRead)
profileUseCase := usecase.NewProfileUseCase(profileRepository, userRepository)
profileHandler := handler.NewProfileHandler(profileUseCase)
e := echo.New()
e.POST("/profiles", profileHandler.CreateProfile)
e.GET("/profiles/:id", profileHandler.FindByID)
port := fmt.Sprintf(":%d", config.Cfg.Port)
e.Logger.Fatal(e.Start(port))
}