You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.1 KiB
Kotlin

4 years ago
package moe.odango.index.http
import com.expediagroup.graphql.SchemaGeneratorConfig
import com.expediagroup.graphql.TopLevelObject
import com.expediagroup.graphql.toSchema
import io.ktor.http.content.resource
import io.ktor.http.content.resources
import io.ktor.http.content.static
import io.ktor.routing.routing
import io.ktor.server.engine.embeddedServer
import io.ktor.server.netty.Netty
import ktor.graphql.GraphQLRouteConfig
import ktor.graphql.graphQL
import moe.odango.index.http.graphql.AnimeService
class Server {
fun run() {
embeddedServer(Netty, port = 3336) {
routing {
graphQL("/graphql",toSchema(
SchemaGeneratorConfig(listOf("moe.odango.index")),
listOf(TopLevelObject(AnimeService()))
)) {
GraphQLRouteConfig(
graphiql = true
)
}
static {
resource("/", "web/index.html")
static("/") {
resources("web")
}
}
}
}
.start(true)
}
}