-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (38 loc) · 1.61 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
package main
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/recover"
"github.com/zakariawahyu/go-hacktiv8-final/config"
"github.com/zakariawahyu/go-hacktiv8-final/controller"
"github.com/zakariawahyu/go-hacktiv8-final/repository"
"github.com/zakariawahyu/go-hacktiv8-final/services"
)
func main() {
db := config.DatabaseConnection()
userRepository := repository.NewUserRepository(db)
photoRepository := repository.NewPhotoRepository(db)
commentRepository := repository.NewCommentRepository(db)
socialMediaRepository := repository.NewSocialMediaRepository(db)
jwtServices := services.NewJWTServices()
userServices := services.NewUserServices(userRepository)
photoServices := services.NewPhotoServices(photoRepository)
commentServices := services.NewCommentServices(commentRepository)
socialMediaServices := services.NewSocialMediaServices(socialMediaRepository)
userController := controller.NewUserController(userServices, jwtServices)
photoController := controller.NewPhotoController(photoServices, jwtServices, userServices)
commentController := controller.NewCommentController(commentServices, jwtServices, userServices)
socialMediaController := controller.NewSocialMediaController(socialMediaServices, jwtServices, userServices)
// Setup Fiber
app := fiber.New(config.NewFiberConfig())
app.Use(recover.New())
app.Get("/", func(ctx *fiber.Ctx) error {
return ctx.Status(fiber.StatusOK).JSON(fiber.Map{
"message": "Hello world!",
})
})
userController.Routes(app)
photoController.Routes(app)
commentController.Routes(app)
socialMediaController.Routes(app)
app.Listen(":8081")
}