package search

import (
	"codeberg.org/mapleopentech/monorepo/cloud/maplepress-backend/config"
	"go.uber.org/zap"
)

// ProvideClient provides a Meilisearch client
func ProvideClient(cfg *config.Config, logger *zap.Logger) (*Client, error) {
	searchConfig := NewConfig(
		cfg.Meilisearch.Host,
		cfg.Meilisearch.APIKey,
		cfg.Meilisearch.IndexPrefix,
	)

	client, err := NewClient(searchConfig, logger)
	if err != nil {
		return nil, err
	}

	return client, nil
}
