{"repo":"raharrison/kotlin-ktor-exposed-starter","free":true,"listed":false,"github":"https://github.com/raharrison/kotlin-ktor-exposed-starter","clone":"git clone https://github.com/raharrison/kotlin-ktor-exposed-starter.git","description":"Starter RESTful service with websocket notifications using Kotlin, Ktor and Exposed with H2, HikariCP and FlyWay","language":"Kotlin","stars":588,"topics":["kotlin","kotlin-coroutines","ktor","exposed","netty","h2-database","jackson","rest-api","websocket","flyway"],"license":null,"category":"networking-infra","readme_excerpt":"Starter project to create a simple RESTful web service in Kotlin Updated for Kotlin 2.4.10, Ktor 3.5.1 and Exposed 1.3.1 Companion article: Getting Started 1. Clone the repo. 2. In the root directory execute ./gradlew run 3. By default, the server will start on port 8080 . See below Routes section for more information. Libraries used: - Ktor - Kotlin async web framework - Netty - Async web server - Kotlin Serialization - JSON serialization/deserialization - Exposed - Kotlin SQL framework - H2 - Embeddable database - HikariCP - High performance JDBC connection pooling - Flyway - Database migrations - JUnit 5, AssertJ and Rest Assured for testing - Kover for code coverage, publishing to Codecov through GitHub Actions The starter project creates a new in-memory H2 database with one table for Widget instances. As ktor is async and based on coroutines, standard blocking JDBC may cause performance issues when used directly on the main thread pool (as threads must be reused for other requests). Therefore, another dedicated thread pool is created for all database queries, alongside connection pooling with HikariCP. Routes: GET /widgets -- get all widgets in the database GET /widgets/{id} -- get one widget instance by id (integer) POST /widgets -- add a new widget to the database by providing a JSON object (converted to a NewWidget instance). e.g - returns PUT /widgets -- update an existing widgets name or quantity. Pass in the id in the JSON request to determine which record to updat","default_branch":null,"files":null,"tree":[],"storefront":"/r/raharrison","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/raharrison/kotlin-ktor-exposed-starter/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}