2020-12-23 17:52:05 +03:30
|
|
|
package ir.armor.tachidesk
|
|
|
|
|
|
2020-12-24 02:08:03 +03:30
|
|
|
import io.javalin.Javalin
|
2020-12-25 13:17:41 +03:30
|
|
|
import ir.armor.tachidesk.util.applicationSetup
|
|
|
|
|
import ir.armor.tachidesk.util.installAPK
|
|
|
|
|
import ir.armor.tachidesk.util.getExtensionList
|
|
|
|
|
import ir.armor.tachidesk.util.getSourceList
|
2020-12-24 02:08:03 +03:30
|
|
|
|
2020-12-23 19:52:16 +03:30
|
|
|
class Main {
|
2020-12-23 17:52:05 +03:30
|
|
|
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 ->
|
|
|
|
|
ctx.header("Access-Control-Allow-Origin", "*") // allow the client which is running on another port
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.get("/api/v1/extensions") { ctx ->
|
|
|
|
|
ctx.json(getExtensionList())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.get("/api/v1/extensions/install/:apkName") { ctx ->
|
|
|
|
|
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
|
|
|
)
|
|
|
|
|
}
|
2020-12-25 06:15:52 +03:30
|
|
|
app.get("/api/v1/sources/") { ctx ->
|
|
|
|
|
ctx.json(getSourceList())
|
|
|
|
|
}
|
2020-12-23 17:52:05 +03:30
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|