package http

import (
	"git.gocasts.ir/ebhomengo/niki/purchaseapp/delivery/http/order"
	orderService "git.gocasts.ir/ebhomengo/niki/purchaseapp/service/order"
	"github.com/labstack/echo/v4"
	"github.com/labstack/echo/v4/middleware"
)

type Server struct {
	OrderHandler *order.Handler
}

func New(orderSvc orderService.Service) *Server {
	return &Server{
		OrderHandler: order.New(orderSvc),
	}
}

func (s *Server) Serve() {
	e := echo.New()
	e.Use(middleware.RequestLogger())
	e.GET("/purchase/health-check", s.healthCheck)

	s.OrderHandler.SetRoutes(e)

	if err := e.Start(":8088"); err != nil {
		e.Logger.Error("failed to start server", "error", err)
	}
}

func (s *Server) Stop() {}
