-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
51 lines (42 loc) · 1.24 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
package main
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/joho/godotenv"
"synapsis-challenge/cmd"
"synapsis-challenge/config"
ireg "synapsis-challenge/internal/adapter/inbound/registry"
"synapsis-challenge/internal/adapter/inbound/rest/group"
"synapsis-challenge/internal/adapter/inbound/rest/handler"
oreg "synapsis-challenge/internal/adapter/outbound/registry"
)
func main() {
godotenv.Load()
app := fiber.New()
app.Use(logger.New(logger.Config{
TimeZone: "Asia/Jakarta",
Format: "${pid} [${ip}]:${port} ${locals:requestid} ${status} - ${method} ${path} ${latency}\n",
TimeFormat: "02-Jan-2006",
}))
db := config.InitMySQL()
rdb := config.InitRedis()
repoReg := oreg.NewRepositoryRegistry(rdb, db)
serviceReg := ireg.NewServiceRegistry(repoReg)
h := handler.New(serviceReg)
group.NewCustomerRequest(app, h)
group.NewProductRequest(app, h)
group.NewShoppingCartRequest(app, h)
group.NewTransactionRequest(app, h)
err := cmd.MigrateAndSeed(db)
if err != nil {
panic(err)
return
}
app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("Hello, World!")
})
app.Get("/stack", func(c *fiber.Ctx) error {
return c.JSON(app.Stack())
})
app.Listen(":3000")
}