package be.vandewalleh import be.vandewalleh.auth.AuthenticationModule import be.vandewalleh.auth.SimpleJWT import be.vandewalleh.extensions.ApplicationBuilder import be.vandewalleh.factories.configurationFactory import be.vandewalleh.factories.dataSourceFactory import be.vandewalleh.factories.databaseFactory import be.vandewalleh.factories.simpleJwtFactory import be.vandewalleh.features.* import be.vandewalleh.services.NoteService import be.vandewalleh.services.UserService import org.kodein.di.Kodein import org.kodein.di.generic.* import org.slf4j.LoggerFactory val mainModule = Kodein.Module("main") { bind() from singleton { NoteService(instance()) } bind() from singleton { UserService(instance(), instance()) } bind() from singleton { configurationFactory() } bind() from setBinding() bind().inSet() with singleton { ErrorHandler() } bind().inSet() with singleton { ContentNegotiationFeature() } bind().inSet() with singleton { CorsFeature(instance().server.cors) } bind().inSet() with singleton { AuthenticationModule(instance(tag = "auth")) } bind().inSet() with singleton { MigrationHook(instance()) } bind().inSet() with singleton { ShutdownDatabaseConnection(instance()) } bind(tag = "auth") with singleton { simpleJwtFactory(instance().jwt.auth) } bind(tag = "refresh") with singleton { simpleJwtFactory(instance().jwt.refresh) } bind() from singleton { LoggerFactory.getLogger("Application") } bind() from singleton { dataSourceFactory(instance().database) } bind() from singleton { databaseFactory(instance()) } bind() from singleton { Migration(instance()) } bind() with singleton { BcryptPasswordHash() } }