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
|
ktor_version=2.2.4
|
||||||
kotlin_version=1.8.10
|
kotlin_version=1.8.10
|
||||||
logback_version=1.2.11
|
logback_version=1.4.6
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
exposed_version=0.41.1
|
exposed_version=0.41.1
|
||||||
h2_version=2.1.214
|
h2_version=2.1.214
|
||||||
|
|
|
@ -1,95 +1,51 @@
|
||||||
package dev.usbharu.hideout
|
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.plugins.*
|
||||||
import dev.usbharu.hideout.repository.IUserAuthRepository
|
import dev.usbharu.hideout.repository.IUserAuthRepository
|
||||||
import dev.usbharu.hideout.repository.IUserRepository
|
import dev.usbharu.hideout.repository.IUserRepository
|
||||||
import dev.usbharu.hideout.repository.UserAuthRepository
|
import dev.usbharu.hideout.repository.UserAuthRepository
|
||||||
import dev.usbharu.hideout.repository.UserRepository
|
import dev.usbharu.hideout.repository.UserRepository
|
||||||
import dev.usbharu.hideout.routing.*
|
import dev.usbharu.hideout.service.IUserAuthService
|
||||||
import dev.usbharu.hideout.service.*
|
import dev.usbharu.hideout.service.activitypub.ActivityPubService
|
||||||
import dev.usbharu.hideout.service.impl.*
|
import dev.usbharu.hideout.service.activitypub.ActivityPubServiceImpl
|
||||||
import io.ktor.client.*
|
import dev.usbharu.hideout.service.impl.UserAuthService
|
||||||
import io.ktor.client.engine.cio.*
|
import dev.usbharu.hideout.service.signature.HttpSignatureVerifyService
|
||||||
import io.ktor.client.plugins.contentnegotiation.*
|
import dev.usbharu.hideout.service.signature.HttpSignatureVerifyServiceImpl
|
||||||
import io.ktor.client.plugins.logging.*
|
|
||||||
import io.ktor.serialization.jackson.*
|
|
||||||
import io.ktor.server.application.*
|
import io.ktor.server.application.*
|
||||||
import org.jetbrains.exposed.sql.Database
|
import org.jetbrains.exposed.sql.Database
|
||||||
import org.koin.ktor.ext.inject
|
import org.koin.ktor.ext.inject
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)
|
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.
|
@Suppress("unused") // application.conf references the main function. This annotation prevents the IDE from marking it as unused.
|
||||||
fun Application.module() {
|
fun Application.module() {
|
||||||
val module = org.koin.dsl.module {
|
|
||||||
|
|
||||||
|
val module = org.koin.dsl.module {
|
||||||
single<Database> {
|
single<Database> {
|
||||||
Database.connect(
|
Database.connect(
|
||||||
url = environment.config.property("hideout.database.url").getString(),
|
url = property("hideout.database.url"),
|
||||||
driver = environment.config.property("hideout.database.driver").getString(),
|
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<IUserRepository> { UserRepository(get()) }
|
||||||
single<IUserAuthRepository> { UserAuthRepository(get()) }
|
single<IUserAuthRepository> { UserAuthRepository(get()) }
|
||||||
single<IUserAuthService> { UserAuthService(get(), get()) }
|
single<IUserAuthService> { UserAuthService(get(), get()) }
|
||||||
single<UserService> { UserService(get()) }
|
single<HttpSignatureVerifyService> { HttpSignatureVerifyServiceImpl(get()) }
|
||||||
single<ActivityPubService> { ActivityPubService() }
|
single<ActivityPubService> { ActivityPubServiceImpl() }
|
||||||
single<ActivityPubUserService> { ActivityPubUserService(get(), get(), get(), get()) }
|
|
||||||
single<IWebFingerService> { WebFingerService(get(), get()) }
|
|
||||||
}
|
}
|
||||||
configureKoin(module)
|
|
||||||
val configData by inject<ConfigData>()
|
|
||||||
Config.configData = configData
|
|
||||||
val decode = Base64.getDecoder().decode("76pc9N9hspQqapj30kCaLJA14O/50ptCg50zCA1oxjA=")
|
|
||||||
|
|
||||||
val pair = "admin" to decode
|
configureKoin(module)
|
||||||
println(pair)
|
|
||||||
val userAuthService by inject<IUserAuthService>()
|
|
||||||
val userService by inject<UserService>()
|
|
||||||
configureSecurity(userAuthService)
|
|
||||||
configureHTTP()
|
configureHTTP()
|
||||||
|
configureSockets()
|
||||||
configureMonitoring()
|
configureMonitoring()
|
||||||
configureSerialization()
|
configureSerialization()
|
||||||
configureSockets()
|
configureRouting(inject<HttpSignatureVerifyService>().value, inject<ActivityPubService>().value)
|
||||||
val activityPubUserService by inject<ActivityPubUserService>()
|
|
||||||
user(userService, activityPubUserService)
|
|
||||||
login()
|
|
||||||
register(userAuthService)
|
|
||||||
wellKnown(userService)
|
|
||||||
val activityPubService by inject<ActivityPubService>()
|
|
||||||
userActivityPubRouting(activityPubService, activityPubUserService)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,17 +3,22 @@ package dev.usbharu.hideout.plugins
|
||||||
import dev.usbharu.hideout.routing.activitypub.inbox
|
import dev.usbharu.hideout.routing.activitypub.inbox
|
||||||
import dev.usbharu.hideout.routing.activitypub.outbox
|
import dev.usbharu.hideout.routing.activitypub.outbox
|
||||||
import dev.usbharu.hideout.routing.activitypub.usersAP
|
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.activitypub.ActivityPubService
|
||||||
import dev.usbharu.hideout.service.signature.HttpSignatureVerifyService
|
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.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)
|
install(AutoHeadResponse)
|
||||||
routing {
|
routing {
|
||||||
inbox(httpSignatureVerifyService, activityPubService)
|
inbox(httpSignatureVerifyService, activityPubService)
|
||||||
outbox()
|
outbox()
|
||||||
usersAP(activityPubService)
|
usersAP(activityPubService)
|
||||||
|
webfinger()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,4 @@ fun Application.configureSerialization() {
|
||||||
install(ContentNegotiation) {
|
install(ContentNegotiation) {
|
||||||
jackson()
|
jackson()
|
||||||
}
|
}
|
||||||
routing {
|
|
||||||
get("/json/kotlinx-serialization") {
|
|
||||||
call.respond(mapOf("hello" to "world"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue