-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (34 loc) · 1.31 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
package main
import (
"github.com/go-playground/validator/v10"
"net/http"
"github.com/michaelact/firstApi/controller"
"github.com/michaelact/firstApi/middleware"
"github.com/michaelact/firstApi/repository"
"github.com/michaelact/firstApi/util/log"
"github.com/michaelact/firstApi/service"
"github.com/michaelact/firstApi/helper"
"github.com/michaelact/firstApi/app"
)
func InitializeServer() *http.Server {
conf := app.NewConfig()
db := app.NewDB(conf)
validate := validator.New()
activityRepository := repository.NewActivityRepository()
activityService := service.NewActivityService(activityRepository, db, validate)
activityController := controller.NewActivityController(activityService)
todoRepository := repository.NewTodoRepository()
todoService := service.NewTodoService(todoRepository, db, validate)
todoController := controller.NewTodoController(todoService)
router := app.NewRouter(activityController, todoController)
authMiddleware := middleware.NewAuthMiddleware(router, conf)
logger := log.NewLogger(conf)
recorderMiddleware := middleware.NewRecorderMiddleware(authMiddleware, logger)
server := app.NewServer(recorderMiddleware, conf)
return server
}
func main() {
server := InitializeServer()
err := server.ListenAndServe()
helper.PanicIfError(err)
}