package handler

import (
	"api_es/internal/config"
	"api_es/internal/repository"
	"api_es/internal/service"
	"api_es/internal/utils"

	"gorm.io/gorm"
)

type AllHandler struct {
	userHandler   *UserHandler
	healthHandler *HealthHandler
}

func NewAllHandler(db *gorm.DB, cfg *config.Config) *AllHandler {

	userRepo := repository.NewUserRepository(db)

	userService := service.NewUserService(userRepo, utils.NewJWTUtil(cfg.JWTSecret))

	userHandler := NewUserHandler(userService)
	healthHandler := NewHealthHandler()

	return &AllHandler{
		userHandler:   userHandler,
		healthHandler: healthHandler,
	}

}

func (h *AllHandler) UserHandler() *UserHandler {
	return h.userHandler
}

func (h *AllHandler) HealthHandler() *HealthHandler {
	return h.healthHandler
}
