Skip to content

About

No description, website, or topics provided.

Resources

Stars

23 stars

Watchers

2 watching

Forks

Latest commit

 

History

2,327 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Latest core

Lightning Server

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)
}

What you get

  • Typed endpoints end to end. Input, output, auth and error cases are Kotlin types; OpenAPI and Kotlin and TypeScript SDKs are generated from them.
  • Swappable services. Database, cache, files, email, SMS and pub/sub are settings. Switch MongoDB for an in-memory store, or Redis for a RAM map, by changing a URL in settings.json.
  • In-memory testing. Server.testBlocking { } runs the real server with no port and no external services; endpoint.test(auth, input) returns the typed result.
  • Infrastructure from the definition. A deployment object reads your settings and writes Terraform for Lambda or EC2, with the database, cache, buckets and alarms they need.
  • Batteries. Auto-CRUD with row and field permissions, live queries, login by PIN, password, TOTP, passkey or OAuth, uploads and image previews, notifications, rate limiting, telemetry and an audit log.

Documentation

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.

Installing

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.

Working on this repository

./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.

License

Apache 2.0. See LICENSE.txt.

About

No description, website, or topics provided.

Resources

Stars

23 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages