-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
36 lines (28 loc) · 900 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
package main
import (
"fmt"
"log"
"github.com/didiyudha/sse-redis/config"
"github.com/didiyudha/sse-redis/domain/product/handler"
"github.com/didiyudha/sse-redis/domain/product/repository"
"github.com/didiyudha/sse-redis/domain/product/usecase"
"github.com/didiyudha/sse-redis/internal/platform/redis"
"github.com/joho/godotenv"
"github.com/labstack/echo/v4"
)
func main() {
godotenv.Load(".env")
config.LoadEnv()
redisConn, err := redis.NewRedis(config.Cfg.Redis)
if err != nil {
log.Fatal(err)
}
productCache := repository.NewProductCache(redisConn)
productUseCase := usecase.NewProductUseCase(productCache)
productHandler := handler.NewProductHandler(productUseCase)
e := echo.New()
e.Debug = true
e.POST("/products", productHandler.Store)
e.GET("/products/streams/:productId", productHandler.Streams)
e.Logger.Fatal(e.Start(fmt.Sprintf(":%d", config.Cfg.Port)))
}