package http

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

type Server struct {
	OrderHandler *orderHandler.Handler
}

func New(orderSvc order.Service) *Server {
	return &Server{
		OrderHandler: orderHandler.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() {}
