package dev.ulfrx.recipe.user

import dev.ulfrx.recipe.shared.Constants
import dev.ulfrx.recipe.shared.dto.MeResponse
import io.ktor.client.HttpClient
import io.ktor.client.call.body
import io.ktor.client.request.get
import org.koin.dsl.module

val userModule =
    module {
        single<UserRepository> {
            UserRepository(
                authSession = get(),
                fetchUser = {
                    get<HttpClient>()
                        .get("${Constants.API_BASE_URL}api/v1/me")
                        .body<MeResponse>()
                        .toUser()
                },
            )
        }
    }
