-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
45 lines (31 loc) · 938 Bytes
/
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
package main
import (
"flag"
"fmt"
"hyphen-backend-SISS/controller"
"hyphen-backend-SISS/system"
"hyphen-backend-SISS/system/initializer"
repository "hyphen-backend-SISS/repository/impl"
service "hyphen-backend-SISS/service/impl"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/recover"
)
var port = `:8080`
func init() {
portPtr := flag.Int("p", 8080, "Enter the port")
flag.Parse()
port = fmt.Sprintf(":%d", *portPtr)
}
func main() {
config := system.NewConfig()
database := initializer.NewDatabase(config)
imageRepository := repository.NewImageRepository(database)
imageService := service.NewImageService(&imageRepository)
imageController := controller.NewImageController(&imageService)
app := fiber.New(initializer.NewFiberConfiguration())
app.Use(recover.New())
app.Use(cors.New())
imageController.Route(app)
app.Listen(port)
}