-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
44 lines (36 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
39
40
41
42
43
44
package main
import (
"gobio/app/controller"
"gobio/app/repository"
"gobio/app/service"
"gobio/config"
"gobio/validation"
"github.com/go-playground/validator/v10"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
func main() {
configuration := config.New()
db := config.NewDatabase(configuration)
// Setup Repository
userRepository := repository.NewUserRepository(db)
linkRepository := repository.NewLinkRepository(db)
// Setup Service
userService := service.NewUserService(&userRepository)
jwtService := service.NewJWTToken(&configuration)
linkService := service.NewLinkService(&linkRepository, &userRepository)
// Setup Controller
userController := controller.NewUserController(&userService, &jwtService)
linkController := controller.NewLinkController(&linkService)
// Setup Echo
e := echo.New()
e.Pre(middleware.RemoveTrailingSlash())
e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
Format: "${protocol} - [${method}], ${host} ${uri}, status=${status}, latency=${latency_human} ${error}\n",
}))
e.Validator = &validation.CustomValidator{Validator: validator.New()}
// Setup Router
userController.Router(e)
linkController.Router(e)
e.Logger.Fatal(e.Start(":8080"))
}