mirror of
https://github.com/ReVanced/revanced-api.git
synced 2026-01-29 06:01:04 +00:00
chore: Use Kotlin for ReVanced API (#169)
This commit converts the entire project to a KTor project written in Kotlin. Various APIs have been updated, removed, or changed. A proxy is present to allow migration between the old and this API, which can serve requests to endpoints from the old API.
This commit is contained in:
46
src/main/kotlin/app/revanced/api/command/StartAPICommand.kt
Normal file
46
src/main/kotlin/app/revanced/api/command/StartAPICommand.kt
Normal file
@@ -0,0 +1,46 @@
|
||||
package app.revanced.api.command
|
||||
|
||||
import app.revanced.api.configuration.*
|
||||
import io.ktor.server.engine.*
|
||||
import io.ktor.server.jetty.*
|
||||
import picocli.CommandLine
|
||||
import java.io.File
|
||||
|
||||
@CommandLine.Command(
|
||||
name = "start",
|
||||
description = ["Start the API server"],
|
||||
)
|
||||
internal object StartAPICommand : Runnable {
|
||||
@CommandLine.Option(
|
||||
names = ["-h", "--host"],
|
||||
description = ["The host address to bind to."],
|
||||
showDefaultValue = CommandLine.Help.Visibility.ALWAYS,
|
||||
)
|
||||
private var host: String = "0.0.0.0"
|
||||
|
||||
@CommandLine.Option(
|
||||
names = ["-p", "--port"],
|
||||
description = ["The port to listen on."],
|
||||
showDefaultValue = CommandLine.Help.Visibility.ALWAYS,
|
||||
)
|
||||
private var port: Int = 8888
|
||||
|
||||
@CommandLine.Option(
|
||||
names = ["-c", "--config"],
|
||||
description = ["The path to the configuration file."],
|
||||
showDefaultValue = CommandLine.Help.Visibility.ALWAYS,
|
||||
)
|
||||
private var configFile = File("configuration.toml")
|
||||
|
||||
override fun run() {
|
||||
embeddedServer(Jetty, port, host) {
|
||||
configureDependencies(configFile)
|
||||
configureHTTP()
|
||||
configureSerialization()
|
||||
configureSecurity()
|
||||
configureOpenAPI()
|
||||
configureLogging()
|
||||
configureRouting()
|
||||
}.start(wait = true)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user