Files
suwayomi-material-you-webui/server/src/main/kotlin/ir/armor/tachidesk/Main.kt

46 lines
1.2 KiB
Kotlin
Raw Normal View History

package ir.armor.tachidesk
2020-12-24 02:08:03 +03:30
import io.javalin.Javalin
import ir.armor.tachidesk.util.*
import java.util.*
2020-12-24 02:08:03 +03:30
2020-12-23 19:52:16 +03:30
class Main {
companion object {
2020-12-24 02:08:03 +03:30
@JvmStatic
fun main(args: Array<String>) {
2020-12-25 02:39:30 +03:30
// make sure everything we need exists
2020-12-25 13:17:41 +03:30
applicationSetup()
2020-12-24 19:37:27 +03:30
2020-12-25 02:39:30 +03:30
val app = Javalin.create().start(4567)
app.before() { ctx ->
2020-12-25 19:29:48 +03:30
// allow the client which is running on another port
ctx.header("Access-Control-Allow-Origin", "*")
2020-12-25 02:39:30 +03:30
}
app.get("/api/v1/extension/list") { ctx ->
2020-12-25 02:39:30 +03:30
ctx.json(getExtensionList())
}
app.get("/api/v1/extension/install/:apkName") { ctx ->
2020-12-25 02:39:30 +03:30
val apkName = ctx.pathParam("apkName")
2020-12-25 03:08:08 +03:30
println(apkName)
2020-12-25 02:39:30 +03:30
ctx.status(
2020-12-25 13:17:41 +03:30
installAPK(apkName)
2020-12-25 02:39:30 +03:30
)
}
app.get("/api/v1/source/list") { ctx ->
2020-12-25 06:15:52 +03:30
ctx.json(getSourceList())
}
app.get("/api/v1/source/:source_id/popular") { ctx ->
val sourceId = ctx.pathParam("source_id")
2020-12-25 19:29:48 +03:30
ctx.json(getPopularManga(sourceId))
}
}
}
}