aboutsummaryrefslogtreecommitdiff
path: root/server/core/src
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-01-17 16:15:56 +0100
committerLinnea Gräf <nea@nea.moe>2025-01-17 16:15:56 +0100
commitd391ce632be29c49a612c64eb5f720238a46844d (patch)
treea0a8b92c9ec550a5c794fc6edaf9fd71e1621490 /server/core/src
parentaa7e28e799ce19f04c6c33782ea8d25ef4c3bb98 (diff)
downloadLocalTransactionLedger-d391ce632be29c49a612c64eb5f720238a46844d.tar.gz
LocalTransactionLedger-d391ce632be29c49a612c64eb5f720238a46844d.tar.bz2
LocalTransactionLedger-d391ce632be29c49a612c64eb5f720238a46844d.zip
feat(server): Add all in one http server
Diffstat (limited to 'server/core/src')
-rw-r--r--server/core/src/main/kotlin/moe/nea/ledger/server/core/Application.kt14
1 files changed, 13 insertions, 1 deletions
diff --git a/server/core/src/main/kotlin/moe/nea/ledger/server/core/Application.kt b/server/core/src/main/kotlin/moe/nea/ledger/server/core/Application.kt
index a177b05..23b2a6a 100644
--- a/server/core/src/main/kotlin/moe/nea/ledger/server/core/Application.kt
+++ b/server/core/src/main/kotlin/moe/nea/ledger/server/core/Application.kt
@@ -8,6 +8,7 @@ import io.ktor.server.plugins.compression.Compression
import io.ktor.server.plugins.contentnegotiation.ContentNegotiation
import io.ktor.server.plugins.cors.routing.CORS
import io.ktor.server.response.respondRedirect
+import io.ktor.server.routing.Routing
import io.ktor.server.routing.get
import io.ktor.server.routing.route
import io.ktor.server.routing.routing
@@ -27,8 +28,17 @@ fun main(args: Array<String>) {
EngineMain.main(args)
}
+interface AIOProvider {
+ fun Routing.installExtraRouting()
+ fun Application.module()
+}
fun Application.module() {
+ val aio = runCatching {
+ Class.forName("moe.nea.ledger.server.aio.AIO")
+ .newInstance() as AIOProvider
+ }.getOrNull()
+ aio?.run { module() }
install(Compression)
install(Documentation) {
info = Info(
@@ -50,7 +60,8 @@ fun Application.module() {
install(CORS) {
anyHost()
}
- val database = Database(File(System.getProperty("ledger.databasefolder")))
+ val database = Database(File(System.getProperty("ledger.databasefolder",
+ "/home/nea/.local/share/PrismLauncher/instances/Skyblock/.minecraft/money-ledger")))
database.loadAndUpgrade()
routing {
route("/api") {
@@ -64,6 +75,7 @@ fun Application.module() {
route("/openapi") {
openApiUi("/api.json")
}
+ aio?.run { installExtraRouting() }
}
}