package patientapp

import (
	"git.gocasts.ir/ebhomengo/niki/patientapp/config"
	"git.gocasts.ir/ebhomengo/niki/patientapp/delivery/http/analytic"
	"git.gocasts.ir/ebhomengo/niki/repository/mysql"
	"github.com/labstack/echo/v4"
)

type Application struct {
	//Config     Config
	HTTPServer *config.EchoServer
	DB         *mysql.DB
}

func Setup(cfg config.Config, db *mysql.DB) Application {

	e := echo.New()

	server := config.EchoServer{
		Router: e,
		Config: cfg,
	}

	return Application{
		//Config:     config,
		HTTPServer: &server,
		DB:         db,
	}
}

func (a Application) Start() {

	server := analytic.NewServer(a.HTTPServer, a.DB)

	_ = server.Serve()
}
