mirror of
https://github.com/revanced/revanced-api.git
synced 2025-04-30 06:34:36 +02:00

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.
47 lines
1.3 KiB
Kotlin
47 lines
1.3 KiB
Kotlin
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)
|
|
}
|
|
}
|