mirror of https://github.com/usbharu/Hideout.git
refactor: 不要なモジュールを削除
This commit is contained in:
parent
ab01b61f55
commit
41ed7ef193
|
@ -1,6 +1,6 @@
|
|||
ktor_version=2.2.4
|
||||
kotlin_version=1.8.10
|
||||
logback_version=1.2.11
|
||||
logback_version=1.4.6
|
||||
kotlin.code.style=official
|
||||
exposed_version=0.41.1
|
||||
h2_version=2.1.214
|
||||
|
|
|
@ -1,95 +1,51 @@
|
|||
package dev.usbharu.hideout
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature
|
||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||
import dev.usbharu.hideout.config.Config
|
||||
import dev.usbharu.hideout.config.ConfigData
|
||||
import dev.usbharu.hideout.plugins.*
|
||||
import dev.usbharu.hideout.repository.IUserAuthRepository
|
||||
import dev.usbharu.hideout.repository.IUserRepository
|
||||
import dev.usbharu.hideout.repository.UserAuthRepository
|
||||
import dev.usbharu.hideout.repository.UserRepository
|
||||
import dev.usbharu.hideout.routing.*
|
||||
import dev.usbharu.hideout.service.*
|
||||
import dev.usbharu.hideout.service.impl.*
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.engine.cio.*
|
||||
import io.ktor.client.plugins.contentnegotiation.*
|
||||
import io.ktor.client.plugins.logging.*
|
||||
import io.ktor.serialization.jackson.*
|
||||
import dev.usbharu.hideout.service.IUserAuthService
|
||||
import dev.usbharu.hideout.service.activitypub.ActivityPubService
|
||||
import dev.usbharu.hideout.service.activitypub.ActivityPubServiceImpl
|
||||
import dev.usbharu.hideout.service.impl.UserAuthService
|
||||
import dev.usbharu.hideout.service.signature.HttpSignatureVerifyService
|
||||
import dev.usbharu.hideout.service.signature.HttpSignatureVerifyServiceImpl
|
||||
import io.ktor.server.application.*
|
||||
import org.jetbrains.exposed.sql.Database
|
||||
import org.koin.ktor.ext.inject
|
||||
import java.util.*
|
||||
|
||||
fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)
|
||||
|
||||
val Application.property: Application.(propertyName: String) -> String
|
||||
get() = {
|
||||
environment.config.property(it).getString()
|
||||
}
|
||||
|
||||
@Suppress("unused") // application.conf references the main function. This annotation prevents the IDE from marking it as unused.
|
||||
fun Application.module() {
|
||||
val module = org.koin.dsl.module {
|
||||
|
||||
val module = org.koin.dsl.module {
|
||||
single<Database> {
|
||||
Database.connect(
|
||||
url = environment.config.property("hideout.database.url").getString(),
|
||||
driver = environment.config.property("hideout.database.driver").getString(),
|
||||
url = property("hideout.database.url"),
|
||||
driver = property("hideout.database.driver"),
|
||||
user = property("hideout.database.username"),
|
||||
password = property("hideout.database.password")
|
||||
)
|
||||
}
|
||||
single<ConfigData> {
|
||||
ConfigData(
|
||||
url = environment.config.propertyOrNull("hideout.url")?.getString()
|
||||
?: environment.config.property("hideout.hostname").getString(),
|
||||
objectMapper = jacksonObjectMapper().enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
|
||||
.setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
|
||||
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
)
|
||||
}
|
||||
single<HttpClient> {
|
||||
HttpClient(CIO) {
|
||||
install(ContentNegotiation) {
|
||||
|
||||
jackson {
|
||||
enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
|
||||
setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
|
||||
configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
}
|
||||
}
|
||||
install(Logging) {
|
||||
logger = Logger.DEFAULT
|
||||
level = LogLevel.ALL
|
||||
}
|
||||
install(httpSignaturePlugin){
|
||||
keyMap = KtorKeyMap(get())
|
||||
}
|
||||
}
|
||||
}
|
||||
single<IUserRepository> { UserRepository(get()) }
|
||||
single<IUserAuthRepository> { UserAuthRepository(get()) }
|
||||
single<IUserAuthService> { UserAuthService(get(), get()) }
|
||||
single<UserService> { UserService(get()) }
|
||||
single<ActivityPubService> { ActivityPubService() }
|
||||
single<ActivityPubUserService> { ActivityPubUserService(get(), get(), get(), get()) }
|
||||
single<IWebFingerService> { WebFingerService(get(), get()) }
|
||||
single<HttpSignatureVerifyService> { HttpSignatureVerifyServiceImpl(get()) }
|
||||
single<ActivityPubService> { ActivityPubServiceImpl() }
|
||||
}
|
||||
configureKoin(module)
|
||||
val configData by inject<ConfigData>()
|
||||
Config.configData = configData
|
||||
val decode = Base64.getDecoder().decode("76pc9N9hspQqapj30kCaLJA14O/50ptCg50zCA1oxjA=")
|
||||
|
||||
val pair = "admin" to decode
|
||||
println(pair)
|
||||
val userAuthService by inject<IUserAuthService>()
|
||||
val userService by inject<UserService>()
|
||||
configureSecurity(userAuthService)
|
||||
configureKoin(module)
|
||||
configureHTTP()
|
||||
configureSockets()
|
||||
configureMonitoring()
|
||||
configureSerialization()
|
||||
configureSockets()
|
||||
val activityPubUserService by inject<ActivityPubUserService>()
|
||||
user(userService, activityPubUserService)
|
||||
login()
|
||||
register(userAuthService)
|
||||
wellKnown(userService)
|
||||
val activityPubService by inject<ActivityPubService>()
|
||||
userActivityPubRouting(activityPubService, activityPubUserService)
|
||||
configureRouting(inject<HttpSignatureVerifyService>().value, inject<ActivityPubService>().value)
|
||||
}
|
||||
|
|
|
@ -3,17 +3,22 @@ package dev.usbharu.hideout.plugins
|
|||
import dev.usbharu.hideout.routing.activitypub.inbox
|
||||
import dev.usbharu.hideout.routing.activitypub.outbox
|
||||
import dev.usbharu.hideout.routing.activitypub.usersAP
|
||||
import dev.usbharu.hideout.routing.wellknown.webfinger
|
||||
import dev.usbharu.hideout.service.activitypub.ActivityPubService
|
||||
import dev.usbharu.hideout.service.signature.HttpSignatureVerifyService
|
||||
import io.ktor.server.routing.*
|
||||
import io.ktor.server.plugins.autohead.*
|
||||
import io.ktor.server.application.*
|
||||
import io.ktor.server.plugins.autohead.*
|
||||
import io.ktor.server.routing.*
|
||||
|
||||
fun Application.configureRouting(httpSignatureVerifyService: HttpSignatureVerifyService,activityPubService: ActivityPubService) {
|
||||
fun Application.configureRouting(
|
||||
httpSignatureVerifyService: HttpSignatureVerifyService,
|
||||
activityPubService: ActivityPubService
|
||||
) {
|
||||
install(AutoHeadResponse)
|
||||
routing {
|
||||
inbox(httpSignatureVerifyService,activityPubService)
|
||||
inbox(httpSignatureVerifyService, activityPubService)
|
||||
outbox()
|
||||
usersAP(activityPubService)
|
||||
webfinger()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,4 @@ fun Application.configureSerialization() {
|
|||
install(ContentNegotiation) {
|
||||
jackson()
|
||||
}
|
||||
routing {
|
||||
get("/json/kotlinx-serialization") {
|
||||
call.respond(mapOf("hello" to "world"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue