package http

import (
	"log/slog"

	"git.eeqj.de/sneak/ipapi/internal/database"
	"git.eeqj.de/sneak/ipapi/internal/state"
	"github.com/go-chi/chi/v5"
	"go.uber.org/fx"
)

// Module provides HTTP server functionality.
//
//nolint:gochecknoglobals // fx module pattern requires global
var Module = fx.Options(
	fx.Provide(
		NewRouter,
		NewServer,
	),
)

// RouterParams contains dependencies for NewRouter.
type RouterParams struct {
	fx.In

	Logger *slog.Logger
	DB     *database.Manager
	State  *state.Manager
}

// NewRouterWrapper wraps NewRouter to work with FX dependency injection.
func NewRouterWrapper(params RouterParams) (chi.Router, error) {
	return NewRouter(params.Logger, params.DB, params.State)
}
