lightning-server
5.0.2indexedDrastically speeds server development with high-level abstractions for databases, cache, email, SMS, and file storage; typed HTTP/WebSocket endpoints, auth flows, auto-generated docs and SDKs, Terraform output.
Drastically speeds server development with high-level abstractions for databases, cache, email, SMS, and file storage; typed HTTP/WebSocket endpoints, auth flows, auto-generated docs and SDKs, Terraform output.
A Kotlin framework for HTTP and WebSocket backends. You declare the whole server in plain Kotlin: endpoints with typed inputs, outputs and auth; the services it needs as settings; tasks and schedules. From that one definition the framework serves requests, generates OpenAPI and typed client SDKs, runs your tests in memory, and writes the Terraform to deploy it on AWS.
object EchoServer : ServerBuilder() {
init { registerBasicMediaTypeCoders() }
// POST /echo
val echo = path.path("echo").post bind ApiHttpHandler(
summary = "Echo a message",
description = "Returns the message back with its character count.",
auth = noAuth,
implementation = { input: EchoRequest ->
EchoResponse(
echo = input.message,
length = input.message.length
)
}
)
}
fun echoServerTest() = EchoServer.testBlocking(settings = {}) {
val result = EchoServer.echo.test(null, EchoRequest("ping"))
check(result.echo == "ping")
check(result.length == 4)
}
The guide lives in docs-guide/guide and is published with MkDocs. Start with:
Kotlin samples in the guide (and in this README) are compiled, and DriftCheckTest fails the build when a code
block and its sample source differ.
Artifacts are in the Lightning Kite Maven repository. Import the stack catalog in settings.gradle.kts:
dependencyResolutionManagement {
repositories {
maven("https://lightningkite-maven.s3.us-west-2.amazonaws.com")
mavenCentral()
}
versionCatalogs {
create("lk") { from("com.lightningkite:stack-catalog:<version>") }
}
}
and depend on modules through it (implementation(lk.lightningserver.core.asProvider())). Each module is versioned
on its own, so take versions from the catalog. Setup has the full build file and
where to find the latest catalog version.
./gradlew build # build and test every module
./gradlew :core:test # one module's tests
./gradlew :docs-guide:test # compile the guide's samples and check the docs match them
./gradlew :demo:run --args="serve" # run the demo server (Ktor); serveNetty and serveJdk also work
./gradlew :demo:run --args="sdk" # regenerate the demo's client SDK
Releases are made by the lk tool, which owns every module's version; don't publish by hand. Notable changes go
in CHANGELOG.md.
Apache 2.0. See LICENSE.txt.
settings.json.Server.testBlocking { } runs the real server with no port and no external services;
endpoint.test(auth, input) returns the typed result.Surfaced from shared tags and platforms — no rankings paid for.