Skip to content

Instantly share code, notes, and snippets.

View holowizor's full-sized avatar

Marek Kwiecień holowizor

View GitHub Profile
@holowizor
holowizor / reactive-ktor-kotlin.kt
Created December 7, 2020 11:00
Reactive ktor application written in Kotlin
@Suppress("unused") // Referenced in application.conf
@kotlin.jvm.JvmOverloads
fun Application.module(testing: Boolean = false) {
install(ContentNegotiation) {
jackson {
enable(SerializationFeature.INDENT_OUTPUT)
}
}
routing {
@holowizor
holowizor / reactive-quarkus-kotlin.kt
Created December 7, 2020 10:58
Reactive quarkus application written in Kotlin
data class HistoricalEntry(val id: Long?, val entryDate: LocalDateTime, val entryKey: String, val entryValue: String) {
companion object {
private fun from(row: Row) = HistoricalEntry(
row.getLong("id"),
row.getLocalDateTime("entry_date"),
row.getString("entry_key"),
row.getString("entry_value"))
fun findAll(client: MySQLPool): Multi<HistoricalEntry> {
return client.query("SELECT * FROM historical_entry ORDER BY entry_date ASC").execute()
@holowizor
holowizor / reactive-spring-kotlin.kt
Created December 7, 2020 10:55
Reactive spring application written in Kotlin
data class HistoricalEntry(@Id val id: Long?, val entryDate: LocalDateTime, val entryKey: String, val entryValue: String)
interface HistoricalEntryRepository : ReactiveCrudRepository<HistoricalEntry, Long> {
@Query("SELECT * FROM historical_entry LIMIT :limit OFFSET :offset ")
suspend fun findAll(limit: Int, offset: Int): Flow<HistoricalEntry>
}
@Configuration
class RouterConfig() {
@Bean
@holowizor
holowizor / serverless.yml
Created October 1, 2019 16:43
Serverless config file for Quarkus native AWS lambda
service: quarkus-lambda
frameworkVersion: ">=1.41.1"
provider:
name: aws
runtime: provided
stage: dev
region: us-west-2
tracing:
@holowizor
holowizor / QuarkusLambda.kt
Created October 1, 2019 16:42
Simple Quarkus Kotlin AWS lambda
package com.patternmatch.dev
import com.amazonaws.services.lambda.runtime.Context
import com.amazonaws.services.lambda.runtime.RequestHandler
import javax.enterprise.context.ApplicationScoped
import javax.inject.Inject
@ApplicationScoped
class EchoPrinter {
fun echo(s: String?) = "you said $s"
@holowizor
holowizor / BootPlain.kt
Created October 1, 2019 16:25
Minimal Spring Boot Kotlin app
package com.patternmatch.dev
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
@SpringBootApplication
class BootPlainApplication
@holowizor
holowizor / QuarkusPlain.kt
Created October 1, 2019 16:21
Minimal Quarkus Kotlin app
package com.patternmatch.dev
import javax.ws.rs.GET
import javax.ws.rs.Path
import javax.ws.rs.Produces
import javax.ws.rs.QueryParam
import javax.ws.rs.core.MediaType
@Path("/echo")
class EchoResource {
@holowizor
holowizor / build.gradle.kts
Created October 1, 2019 16:16
Minimal quarkus + kotlin gradle build script
import io.quarkus.gradle.tasks.QuarkusNative
group = "com.patternmatch"
version = "1.0-SNAPSHOT"
plugins {
kotlin("jvm") version "1.3.41"
id("io.quarkus") version "0.22.0"
id("org.jetbrains.kotlin.plugin.allopen") version "1.3.41"
}

Keybase proof

I hereby claim:

  • I am holowizor on github.
  • I am marekkwiecien (https://keybase.io/marekkwiecien) on keybase.
  • I have a public key ASAapYIwdw_2gBYL4bN34yyW5NkixoehPcCWzTt63RwIWAo

To claim this, I am signing this object: