mirror of
https://github.com/revanced/revanced-api.git
synced 2025-04-30 06:34:36 +02:00
50 lines
1.4 KiB
Kotlin
50 lines
1.4 KiB
Kotlin
package app.revanced.api.command
|
|
|
|
import app.revanced.api.configuration.*
|
|
import io.github.cdimascio.dotenv.Dotenv
|
|
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() {
|
|
Dotenv.configure().systemProperties().load()
|
|
|
|
embeddedServer(Jetty, port, host) {
|
|
configureDependencies(configFile)
|
|
configureHTTP()
|
|
configureSerialization()
|
|
configureSecurity()
|
|
configureOpenAPI()
|
|
configureLogging()
|
|
configureRouting()
|
|
}.start(wait = true)
|
|
}
|
|
}
|