package cy.hexor.furumi.di

import android.content.Context
import cy.hexor.furumi.data.local.AuthSessionStorage
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object StorageModule {

    @Provides
    @Singleton
    fun provideMoshi(): Moshi {
        return Moshi.Builder()
            .add(KotlinJsonAdapterFactory())
            .build()
    }

    @Provides
    @Singleton
    fun provideAuthSessionStorage(
        @ApplicationContext context: Context,
        moshi: Moshi
    ): AuthSessionStorage {
        return AuthSessionStorage(context, moshi)
    }
}
