Gradle multi-module project that is comprised of two modules A, B and C. Module A exposes functionality (e.g. json serialization configurations) that is consumed by module B and C. Module A also has a set of test helpers (in src/test/) that are useful so that modules B and C are not concerned with bootstrapping the serialization part on their unit tests.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Should the database be indexed at startup (using Compass:GPS)? | |
* | |
* Possible values: true|false|"fork" | |
* | |
* The value may be a boolean true|false or a string "fork", which means true, | |
* and fork a thread for it | |
* | |
* If you use BootStrap.groovy to insert your data then you should use "true", | |
* which means do a non-forking, otherwise "fork" is recommended |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.slf4j.LoggerFactory | |
class MimeTypeDetector private constructor() { | |
private val log = LoggerFactory.getLogger(MimeTypeDetector::class.java) | |
private var extensionToMimeTypeMapping: MutableMap<String, String> = mutableMapOf() | |
private var mimeTypeToExtensionMapping: MutableMap<String, String> = mutableMapOf() | |
companion object { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.ktor.application.ApplicationCall | |
import io.ktor.http.URLBuilder | |
import io.ktor.http.takeFrom | |
import io.ktor.util.createFromCall | |
import io.ktor.application.call | |
import io.ktor.http.HttpStatusCode | |
import io.ktor.request.receive | |
import io.ktor.response.respond | |
import io.ktor.routing.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io.ktor.http.ContentType | |
// Resource definition | |
data class MyResource(val name:String) | |
// Content-type definition | |
object MyContentTypes { | |
object v1 { | |
val MyResource = ContentType("application", "vnd.app.myResource-v1+json") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.example | |
import com.zaxxer.hikari.HikariConfig | |
import com.zaxxer.hikari.HikariDataSource | |
import io.ktor.application.call | |
import io.ktor.http.HttpStatusCode | |
import io.ktor.request.receive | |
import io.ktor.response.respond | |
import io.ktor.routing.Route | |
import io.ktor.routing.get |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** | |
* AWS Cognito signs the tokens using the RS256 algorithm. Contrary to most common examples (using HMAC + SHA256) that use | |
* a shared secret, the RS256 uses assymetric crytography, so in order to validate the JWT we need to obtain the public key | |
* that matches the private key used to generate the token signature. | |
* Therefore, the critical step is to download the public key from the discovery endpoint. | |
* Cognito makes this available as a JWKS, JSON Web Key Set, available at a well known location of your user pool | |
* e.g. https://cognito-idp.{region}.amazonaws.com/{user-pool-id}/.well-known/jwks.json | |
* Furthermore, the issuer of the token is the user pool (the iss clamin is the user pool URL) and the audience is the | |
* particular client that was configured on the user pool (the aud claim is set to a specific client id of that pool). | |
* See: https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-client-apps.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* AWS CDK integration. Changes the mainClassName variable and calls run | |
* */ | |
def cdkMainClassName = "com.rideal.infrastructure.aws.RidealApp" | |
def originalMainClassName = mainClassName | |
tasks.register("run-cdk") { | |
description "Specific run-script for AWS CDK integration" | |
group "CDK" |