GithubHelp home page GithubHelp logo

zwartzon / klite Goto Github PK

View Code? Open in Web Editor NEW

This project forked from codeborne/klite

0.0 0.0 0.0 582 KB

Kotlin async http server framework with coroutines and zero deps

License: MIT License

Kotlin 100.00%

klite's Introduction

Klite

Build & Test

A very light-weight (lite) non-blocking http framework for Kotlin coroutines on JVM.

Inspired by SparkJava, Jooby, etc, but smaller, simpler and better.

Goals

  • Proper Kotlin coroutine support with working before/after filters for e.g. transactions and logging
  • Minimal amount of code
    • Simple to maintain & change
    • Performance is also important, but simplicity is preferred
  • Zero dependencies - Java built-in jdk.httpserver is used under the hood
    • Perfect for microservices
    • But still possible to easily add support for other servers if needed
    • Sample docker image is about 50-70Mb thanks to jlink, depending on used modules
  • 12-factor apps by default
  • Most behaviour can be overridden if necessary
  • Both route builder and annotated classes
  • Very easy to do simple things, e.g. @GET suspend fun route() = provider.fetchData()
  • Most app code will not depend on the framework, easy to switch
  • Not much need for documentation - the source code is short and readable.

Dependencies

  • Java 6+ built-in non-blocking jdk.httpserver
  • Re-routable Java 9+ System.Logger

Modules

  • server - the main server module. See it's docs. Zero external dependencies.
  • jackson - adds json parsing/rendering using Jackson
  • serialization - adds json parsing/rendering using kotlinx-serialization
  • slf4j - redirects server logs to slf4j and configures it
  • i18n - simple server-side translations (for emails, etc)
  • jdbc - provides jdbc extensions and transaction handling (depends on slf4j because of Hikari)
  • jdbc-test - provides a way of testing your DB code using a real DB
  • jobs - provides a simple scheduled JobRunner
  • liquibase - allows to use liquibase for DB migration

Status

The core server is less than 1000 lines of code.

Klite powers a few production apps already. Public announcement at KKON 2022, see the slides.

Usage

See the sample subproject on how to build apps with Klite and run them in Docker.

Klite builds are available from jitpack.

Release

  repositories {
    mavenCentral()
    maven { url = uri("https://jitpack.io") }
  }

  dependencies {
    val kliteVersion = "master-SNAPSHOT" // you can put a released tag or commit hash here
    implementation("com.github.codeborne.klite:klite-server:$kliteVersion")
    // Plus any optional components with their own external dependencies, see above for list
    implementation("com.github.codeborne.klite:klite-jackson:$kliteVersion")
    implementation("com.github.codeborne.klite:klite-jdbc:$kliteVersion")
    testImplementation("com.github.codeborne.klite:klite-jdbc-test:$kliteVersion")
    ...
  }

Using unreleased commits

Jitpack builds requested versions on the fly, so it is also good if you want to fork Klite and customize for your own needs - you will still be able to add your fork as a Maven/Gradle dependency in your apps.

But pull-requests are welcome if you want to improve something for everybody!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.