Skip to content

Commit e47bc38

Browse files
committed
Update versions
1 parent 3cb0f26 commit e47bc38

File tree

22 files changed

+145
-232
lines changed

22 files changed

+145
-232
lines changed

build.gradle.kts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
22

33
@Suppress("DSL_SCOPE_VIOLATION") plugins {
44
application
5-
alias(libs.plugins.kotest.multiplatform)
6-
id(libs.plugins.kotlin.jvm.pluginId)
5+
alias(libs.plugins.kotlin.jvm)
6+
alias(libs.plugins.kotlin.assert)
77
alias(libs.plugins.kover)
88
alias(libs.plugins.kotlinx.serialization)
9+
alias(libs.plugins.kotest.multiplatform)
910
alias(libs.plugins.sqldelight)
1011
alias(libs.plugins.ktor)
1112
alias(libs.plugins.spotless)
12-
alias(libs.plugins.kotlin.assert)
13+
alias(libs.plugins.version.catalog.update)
1314
}
1415

1516
application {
@@ -25,10 +26,6 @@ sqldelight {
2526
}
2627
}
2728

28-
repositories {
29-
mavenCentral()
30-
}
31-
3229
tasks {
3330
withType<KotlinCompile>().configureEach {
3431
kotlin.compilerOptions.freeCompilerArgs.add("-Xcontext-receivers")
@@ -41,16 +38,18 @@ tasks {
4138

4239
ktor {
4340
docker {
44-
jreVersion = JavaVersion.VERSION_19
41+
jreVersion = JavaVersion.VERSION_21
4542
localImageName = "ktor-arrow-example"
46-
imageTag = "latest"
4743
}
4844
}
4945

5046
spotless {
5147
kotlin {
5248
targetExclude("**/build/**")
53-
ktfmt("0.46").googleStyle()
49+
ktfmt().googleStyle().configure {
50+
it.setRemoveUnusedImports(true)
51+
it.setManageTrailingCommas(true)
52+
}
5453
}
5554
}
5655

buildSrc/build.gradle.kts

Lines changed: 0 additions & 15 deletions
This file was deleted.

buildSrc/settings.gradle.kts

Lines changed: 0 additions & 5 deletions
This file was deleted.

buildSrc/src/main/kotlin/io/github/nomisrev/Detekt.kt

Lines changed: 0 additions & 29 deletions
This file was deleted.

buildSrc/src/main/kotlin/predef.kt

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 74 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,115 @@
11
[versions]
22
arrow = "2.0.1"
3-
coroutines = "1.7.3"
4-
kotlin = "2.1.10"
3+
cohort = "2.6.1"
4+
coroutines = "1.10.1"
5+
detekt = "1.23.8"
6+
hikari = "6.3.0"
7+
kjwt = "1.0.0"
58
kotest = "5.9.1"
9+
kotest-arrow = "2.0.0"
10+
kotest-testcontainers = "2.0.2"
11+
kotlin = "2.1.20"
612
kover = "0.9.1"
7-
detekt = "1.23.7"
8-
ktor = "3.1.0"
9-
logback = "1.5.16"
10-
sqldelight="2.0.2"
11-
testcontainers="1.20.4"
12-
hikari="6.2.1"
13-
postgresql="42.7.5"
14-
kjwt="1.0.0"
15-
kotest-arrow="2.0.0"
16-
kotest-testcontainers="2.0.2"
17-
slugify="3.0.7"
18-
suspendapp="0.4.0"
19-
cohort="2.6.1"
20-
spotless="7.0.2"
13+
ktor = "3.1.2"
14+
logback = "1.5.18"
15+
postgresql = "42.7.5"
16+
slugify = "3.0.7"
17+
spotless = "7.0.2"
18+
sqldelight = "2.0.2"
19+
suspendapp = "0.5.0"
20+
testcontainers = "1.20.6"
21+
version-catalog-update = "1.0.0"
2122

2223
[libraries]
2324
arrow-core = { module = "io.arrow-kt:arrow-core", version.ref = "arrow" }
24-
arrow-optics = { module = "io.arrow-kt:arrow-optics", version.ref = "arrow" }
2525
arrow-fx = { module = "io.arrow-kt:arrow-fx-coroutines", version.ref = "arrow" }
26-
suspendapp = { module = "io.arrow-kt:suspendapp", version.ref = "suspendapp" }
27-
suspendapp-ktor = { module = "io.arrow-kt:suspendapp-ktor", version.ref = "suspendapp" }
26+
arrow-optics = { module = "io.arrow-kt:arrow-optics", version.ref = "arrow" }
27+
cohort-hikari = { module = "com.sksamuel.cohort:cohort-hikari", version.ref = "cohort" }
28+
cohort-ktor = { module = "com.sksamuel.cohort:cohort-ktor", version.ref = "cohort" }
2829
coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm", version.ref = "coroutines" }
2930
coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines" }
31+
detekt-gradle = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" }
32+
hikari = { module = "com.zaxxer:HikariCP", version.ref = "hikari" }
33+
kjwt-core = { module = "io.github.nefilim.kjwt:kjwt-core", version.ref = "kjwt" }
34+
kotest-arrow = { module = "io.kotest.extensions:kotest-assertions-arrow", version.ref = "kotest-arrow" }
35+
kotest-arrow-fx = { module = "io.kotest.extensions:kotest-assertions-arrow-fx-coroutines", version.ref = "kotest-arrow" }
3036
kotest-assertionsCore = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" }
3137
kotest-frameworkEngine = { module = "io.kotest:kotest-framework-engine", version.ref = "kotest" }
3238
kotest-property = { module = "io.kotest:kotest-property", version.ref = "kotest" }
3339
kotest-runnerJUnit5 = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" }
34-
kotest-arrow = { module = "io.kotest.extensions:kotest-assertions-arrow", version.ref = "kotest-arrow" }
35-
kotest-arrow-fx = { module = "io.kotest.extensions:kotest-assertions-arrow-fx-coroutines", version.ref = "kotest-arrow" }
3640
kotest-testcontainers = { module = "io.kotest.extensions:kotest-extensions-testcontainers", version.ref = "kotest-testcontainers" }
41+
kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
42+
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
43+
ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
44+
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
45+
ktor-client-resources = { module = "io.ktor:ktor-client-resources", version.ref = "ktor" }
46+
ktor-client-serialization = { module = "io.ktor:ktor-client-serialization", version.ref = "ktor" }
47+
ktor-serialization = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
48+
ktor-server-auth = { module = "io.ktor:ktor-server-auth", version.ref = "ktor" }
49+
ktor-server-auth-jwt = { module = "io.ktor:ktor-server-auth-jwt", version.ref = "ktor" }
3750
ktor-server-content-negotiation = { module = "io.ktor:ktor-server-content-negotiation", version.ref = "ktor" }
3851
ktor-server-core = { module = "io.ktor:ktor-server-core", version.ref = "ktor" }
3952
ktor-server-cors = { module = "io.ktor:ktor-server-cors", version.ref = "ktor" }
4053
ktor-server-defaultheaders = { module = "io.ktor:ktor-server-default-headers", version.ref = "ktor" }
54+
ktor-server-html = { module = "io.ktor:ktor-server-html-builder", version.ref = "ktor" }
4155
ktor-server-netty = { module = "io.ktor:ktor-server-netty", version.ref = "ktor" }
42-
ktor-server-tests = { module = "io.ktor:ktor-server-test-host", version.ref = "ktor" }
43-
ktor-server-auth = { module = "io.ktor:ktor-server-auth", version.ref = "ktor" }
44-
ktor-server-auth-jwt = { module = "io.ktor:ktor-server-auth-jwt", version.ref = "ktor" }
4556
ktor-server-resources = { module = "io.ktor:ktor-server-resources", version.ref = "ktor" }
46-
ktor-client-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
47-
ktor-client-cio = { module = "io.ktor:ktor-client-cio", version.ref = "ktor" }
48-
ktor-client-serialization = { module = "io.ktor:ktor-client-serialization", version.ref = "ktor" }
49-
ktor-client-content-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
50-
ktor-client-resources = { module = "io.ktor:ktor-client-resources", version.ref = "ktor" }
51-
ktor-serialization = { module = "io.ktor:ktor-serialization-kotlinx-json", version.ref = "ktor" }
52-
ktor-server-html = { module = "io.ktor:ktor-server-html-builder", version.ref = "ktor" }
57+
ktor-server-tests = { module = "io.ktor:ktor-server-test-host", version.ref = "ktor" }
5358
logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }
54-
kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
55-
detekt-gradle = { module = "io.gitlab.arturbosch.detekt:detekt-gradle-plugin", version.ref = "detekt" }
59+
postgresql = { module = "org.postgresql:postgresql", version.ref = "postgresql" }
60+
slugify = { module = "com.github.slugify:slugify", version.ref = "slugify" }
61+
sqldelight-jdbc = { module = "app.cash.sqldelight:jdbc-driver", version.ref = "sqldelight" }
62+
sqldelight-postgresql = { module = "app.cash.sqldelight:postgresql-dialect", version.ref = "sqldelight" }
63+
suspendapp = { module = "io.arrow-kt:suspendapp", version.ref = "suspendapp" }
64+
suspendapp-ktor = { module = "io.arrow-kt:suspendapp-ktor", version.ref = "suspendapp" }
5665
testcontainers-postgresql = { module = "org.testcontainers:postgresql", version.ref = "testcontainers" }
57-
hikari = { module = "com.zaxxer:HikariCP", version.ref="hikari" }
58-
sqldelight-jdbc = { module = "app.cash.sqldelight:jdbc-driver", version.ref="sqldelight" }
59-
sqldelight-postgresql = { module = "app.cash.sqldelight:postgresql-dialect", version.ref="sqldelight" }
60-
postgresql = { module="org.postgresql:postgresql", version.ref="postgresql" }
61-
kjwt-core = { module="io.github.nefilim.kjwt:kjwt-core", version.ref="kjwt" }
62-
slugify = { module="com.github.slugify:slugify", version.ref="slugify" }
63-
cohort-ktor = { module="com.sksamuel.cohort:cohort-ktor", version.ref="cohort" }
64-
cohort-hikari = { module="com.sksamuel.cohort:cohort-hikari", version.ref="cohort" }
6566

6667
[bundles]
67-
arrow = ["arrow-core", "arrow-fx"]
68-
suspendapp = ["suspendapp", "suspendapp-ktor"]
69-
ktor-server = [
70-
"ktor-server-core",
71-
"ktor-server-cors",
72-
"ktor-server-content-negotiation",
73-
"ktor-server-defaultheaders",
74-
"ktor-server-netty",
75-
"ktor-server-auth",
76-
"ktor-serialization",
77-
"ktor-server-resources"
68+
arrow = [
69+
"arrow-core",
70+
"arrow-fx",
7871
]
79-
ktor-client = [
80-
"ktor-client-content-negotiation",
81-
"ktor-client-serialization",
82-
"ktor-client-resources"
72+
cohort = [
73+
"cohort-hikari",
74+
"cohort-ktor",
8375
]
8476
kotest = [
77+
"kotest-arrow",
78+
"kotest-arrow-fx",
8579
"kotest-assertionsCore",
8680
"kotest-frameworkEngine",
8781
"kotest-property",
8882
"kotest-runnerJUnit5",
89-
"kotest-arrow",
90-
"kotest-arrow-fx",
91-
"kotest-testcontainers"
83+
"kotest-testcontainers",
9284
]
93-
cohort = [
94-
"cohort-ktor",
95-
"cohort-hikari"
85+
ktor-client = [
86+
"ktor-client-content-negotiation",
87+
"ktor-client-resources",
88+
"ktor-client-serialization",
89+
]
90+
ktor-server = [
91+
"ktor-serialization",
92+
"ktor-server-auth",
93+
"ktor-server-content-negotiation",
94+
"ktor-server-core",
95+
"ktor-server-cors",
96+
"ktor-server-defaultheaders",
97+
"ktor-server-netty",
98+
"ktor-server-resources",
99+
]
100+
suspendapp = [
101+
"suspendapp",
102+
"suspendapp-ktor",
96103
]
97104

98105
[plugins]
99-
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
106+
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
100107
kotest-multiplatform = { id = "io.kotest.multiplatform", version.ref = "kotest" }
108+
kotlin-assert = { id = "org.jetbrains.kotlin.plugin.power-assert", version.ref = "kotlin" }
101109
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
102-
kotlin-assert = { id = "org.jetbrains.kotlin.plugin.power-assert", version.ref = "kotlin" }
103-
detekt = { id = "io.gitlab.arturbosch.detekt", version.ref = "detekt" }
104110
kotlinx-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
105-
sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" }
111+
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
106112
ktor = { id = "io.ktor.plugin", version.ref = "ktor" }
107113
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
114+
sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" }
115+
version-catalog-update = { id = "nl.littlerobots.version-catalog-update", version.ref = "version-catalog-update" }

settings.gradle.kts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,7 @@
11
rootProject.name = "ktor-arrow-sample"
22

3-
plugins {
4-
id("com.gradle.enterprise") version "3.15.1"
5-
}
6-
73
dependencyResolutionManagement {
8-
versionCatalogs {
9-
create("libs") {
10-
from(files("libs.versions.toml"))
11-
}
12-
}
13-
144
repositories {
155
mavenCentral()
166
}
177
}
18-
19-
gradleEnterprise {
20-
buildScan {
21-
termsOfServiceUrl = "https://gradle.com/terms-of-service"
22-
termsOfServiceAgree = "yes"
23-
}
24-
}

src/main/kotlin/io/github/nomisrev/auth/jwt.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ data class JwtContext(val token: JwtToken, val userId: UserId)
1818
// Small middleware to validate JWT token without using Ktor Auth / Nullable principle
1919
suspend inline fun RoutingContext.jwtAuth(
2020
jwtService: JwtService,
21-
crossinline body: suspend RoutingContext.(JwtContext) -> Unit
21+
crossinline body: suspend RoutingContext.(JwtContext) -> Unit,
2222
) {
2323
optionalJwtAuth(jwtService) { context ->
2424
context?.let { body(this, it) } ?: call.respond(HttpStatusCode.Unauthorized)
@@ -27,14 +27,14 @@ suspend inline fun RoutingContext.jwtAuth(
2727

2828
suspend inline fun RoutingContext.optionalJwtAuth(
2929
jwtService: JwtService,
30-
crossinline body: suspend RoutingContext.(JwtContext?) -> Unit
30+
crossinline body: suspend RoutingContext.(JwtContext?) -> Unit,
3131
) {
3232
jwtToken()?.let { token ->
3333
jwtService
3434
.verifyJwtToken(JwtToken(token))
3535
.fold(
3636
{ error -> call.respond(error) },
37-
{ userId -> body(this, JwtContext(JwtToken(token), userId)) }
37+
{ userId -> body(this, JwtContext(JwtToken(token), userId)) },
3838
)
3939
} ?: body(this, null)
4040
}

src/main/kotlin/io/github/nomisrev/env/Dependencies.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Dependencies(
2424
val articleService: ArticleService,
2525
val healthCheck: HealthCheckRegistry,
2626
val tagPersistence: TagPersistence,
27-
val userPersistence: UserPersistence
27+
val userPersistence: UserPersistence,
2828
)
2929

3030
suspend fun ResourceScope.dependencies(env: Env): Dependencies {

src/main/kotlin/io/github/nomisrev/env/Env.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ data class Env(
3333
data class Auth(
3434
val secret: String = getenv("JWT_SECRET") ?: AUTH_SECRET,
3535
val issuer: String = getenv("JWT_ISSUER") ?: AUTH_ISSUER,
36-
val duration: Duration = (getenv("JWT_DURATION")?.toIntOrNull() ?: AUTH_DURATION).days
36+
val duration: Duration = (getenv("JWT_DURATION")?.toIntOrNull() ?: AUTH_DURATION).days,
3737
)
3838
}

0 commit comments

Comments
 (0)