-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
68 lines (52 loc) · 2.05 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
package main
import (
"fmt"
"github.com/dennyaris/todo-list/config"
"github.com/dennyaris/todo-list/deliveries/helpers"
"github.com/dennyaris/todo-list/deliveries/middlewares"
"github.com/dennyaris/todo-list/deliveries/routes"
cm "github.com/dennyaris/todo-list/repositories/client"
pm "github.com/dennyaris/todo-list/repositories/post"
um "github.com/dennyaris/todo-list/repositories/user"
cs "github.com/dennyaris/todo-list/services/client"
ps "github.com/dennyaris/todo-list/services/post"
"github.com/dennyaris/todo-list/services/renderer"
us "github.com/dennyaris/todo-list/services/user"
"github.com/dennyaris/todo-list/services/validation"
cc "github.com/dennyaris/todo-list/deliveries/controllers/client"
pc "github.com/dennyaris/todo-list/deliveries/controllers/post"
uc "github.com/dennyaris/todo-list/deliveries/controllers/user"
"github.com/gorilla/sessions"
"github.com/labstack/echo-contrib/session"
"github.com/labstack/echo/v4"
)
func main() {
server := echo.New()
middlewares.General(server)
server.HTTPErrorHandler = helpers.CustomHTTPErrorHandler
server.Use(session.Middleware(sessions.NewCookieStore([]byte(config.GetConfig().Secret_JWT))))
// database connection
db := config.InitDB(*config.GetConfig())
config.AutoMigrate(db)
// models
userModel := um.NewUserModel(db)
postModel := pm.NewPostModel(db)
// services
validate := validation.NewValidation()
userService := us.NewUserService(userModel)
postService := ps.NewPostService(postModel)
// controllers
userController := uc.NewUserController(userService, validate)
postController := pc.NewPostController(postService, validate)
// routes
routes.UserPath(server, userController)
routes.PostPath(server, postController)
// Register Renderer
server.Renderer = renderer.NewRenderer()
// Client
clientModel := cm.NewClientModel()
clientService := cs.NewClientService(clientModel)
clientController := cc.NewClientController(clientService)
routes.ClientPath(server, clientController)
server.Logger.Fatal(server.Start(fmt.Sprintf(":%s", config.GetConfig().Port)))
}