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
get<Routes.TODO> { // this: PipelineContext<Unit, ApplicationCall> | |
TodoRepositoryImpl.getAll() // it is launched here 🚀 | |
} |
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
class TodoRepositoryImpl: TodoRepository { | |
override suspend fun create(todo: Todo): Todo = newSuspendedTransaction{ | |
TodoModel.new{ | |
subject = todo.subject | |
done = todo.done | |
}.toEntity() | |
} | |
override suspend fun getAll(): List<Todo> = newSuspendedTransaction{ | |
TodoModel.all().map(TodoModel::toEntity) | |
} |
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
// Define | |
class TodoModel(uid: EntityID<UUID>): UUIDEntity(uid) { | |
companion object: UUIDEntityClass<TodoModel>(TodoTable) | |
var subject by TodoTable.subject | |
var done by TodoTable.done | |
} |
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
// Define a table | |
object TodoTable: UUIDTable(name = "todo", columnName = "uid") { | |
val subject: Column<String> = text(name = "subject") | |
val done: Column<Boolean> = bool(name = "done") | |
} |
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
fun Application.module(testing: Boolean = false) { | |
// ... | |
val database: AppDatabase by inject() | |
database.init() | |
} |
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
@KtorExperimentalAPI | |
class AppDatabase( | |
private val config: ApplicationConfig | |
) { | |
lateinit var dataSource: DataSource | |
fun init() { | |
connectionPool() | |
orm() | |
} | |
private fun connectionPool() { |
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
ktor { | |
... | |
database { | |
connection { | |
jdbc = "jdbc:postgresql://localhost:5432/postgres" | |
jdbc = ${?DATABASE_JDBC} | |
user = admin | |
user = ${?DATABASE_USER} | |
password = admin | |
password = ${?DATABASE_PASSWORD} |
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
# For development purpose only | |
version: "3.7" | |
services: | |
postgres: | |
image: postgres:12-alpine | |
restart: always | |
environment: | |
POSTGRES_DB: postgres | |
POSTGRES_USER: admin | |
POSTGRES_PASSWORD: admin |
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
plugins { | |
id("org.openapi.generator") version "5.1.1" | |
} | |
openApiGenerate { | |
generatorName.set("kotlin") | |
inputSpec.set("./api-client.yml") | |
outputDir.set("$buildDir") | |
apiPackage.set("com.innovorder.data.api") | |
modelPackage.set("com.innovorder.data.models") |
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
object Kotlin { | |
const val version = "1.5.0" | |
} | |
object Ktor { | |
const val version = "1.5.4" | |
} | |
object Moshi { | |
const val version = "1.12.0" |
NewerOlder