Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Commit

Permalink
🎨 Fix ktlint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bakseter committed Dec 26, 2023
1 parent 556c911 commit 7dd8ed2
Show file tree
Hide file tree
Showing 37 changed files with 1,260 additions and 1,057 deletions.
68 changes: 34 additions & 34 deletions backend/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import com.adarshr.gradle.testlogger.theme.ThemeType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

val ktor_version: String by project
val logback_version: String by project
val exposed_version: String by project
val postgres_version: String by project
val hikari_version: String by project
val kotest_version: String by project
val flyway_version: String by project
val ktorVersion: String by project
val logbackVersion: String by project
val exposedVersion: String by project
val postgresVersion: String by project
val hikariVersion: String by project
val kotestVersion: String by project
val flywayVersion: String by project

// Needed for Shadow
project.setProperty("mainClassName", "no.uib.echo.ApplicationKt")
Expand All @@ -33,40 +33,40 @@ repositories {
}

dependencies {
implementation("io.ktor:ktor-server-core:$ktor_version")
implementation("io.ktor:ktor-server-netty:$ktor_version")
implementation("io.ktor:ktor-server-content-negotiation:$ktor_version")
implementation("io.ktor:ktor-server-cors:$ktor_version")
implementation("io.ktor:ktor-server-auth:$ktor_version")
implementation("io.ktor:ktor-server-auth-jwt:$ktor_version")
implementation("io.ktor:ktor-server-rate-limit:$ktor_version")
implementation("io.ktor:ktor-server-openapi:$ktor_version")
implementation("io.ktor:ktor-server-swagger:$ktor_version")
implementation("io.ktor:ktor-server-core:$ktorVersion")
implementation("io.ktor:ktor-server-netty:$ktorVersion")
implementation("io.ktor:ktor-server-content-negotiation:$ktorVersion")
implementation("io.ktor:ktor-server-cors:$ktorVersion")
implementation("io.ktor:ktor-server-auth:$ktorVersion")
implementation("io.ktor:ktor-server-auth-jwt:$ktorVersion")
implementation("io.ktor:ktor-server-rate-limit:$ktorVersion")
implementation("io.ktor:ktor-server-openapi:$ktorVersion")
implementation("io.ktor:ktor-server-swagger:$ktorVersion")

implementation("io.ktor:ktor-client-core:$ktor_version")
implementation("io.ktor:ktor-client-cio:$ktor_version")
implementation("io.ktor:ktor-client-logging:$ktor_version")
implementation("io.ktor:ktor-client-serialization:$ktor_version")
implementation("io.ktor:ktor-client-content-negotiation:$ktor_version")
implementation("io.ktor:ktor-client-core:$ktorVersion")
implementation("io.ktor:ktor-client-cio:$ktorVersion")
implementation("io.ktor:ktor-client-logging:$ktorVersion")
implementation("io.ktor:ktor-client-serialization:$ktorVersion")
implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion")

implementation("io.ktor:ktor-serialization-kotlinx-json:$ktor_version")
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")

implementation("ch.qos.logback:logback-classic:$logback_version")
implementation("ch.qos.logback:logback-classic:$logbackVersion")

implementation("org.jetbrains.exposed:exposed-core:$exposed_version")
implementation("org.jetbrains.exposed:exposed-dao:$exposed_version")
implementation("org.jetbrains.exposed:exposed-jdbc:$exposed_version")
implementation("org.jetbrains.exposed:exposed-jodatime:$exposed_version")
implementation("org.jetbrains.exposed:exposed-core:$exposedVersion")
implementation("org.jetbrains.exposed:exposed-dao:$exposedVersion")
implementation("org.jetbrains.exposed:exposed-jdbc:$exposedVersion")
implementation("org.jetbrains.exposed:exposed-jodatime:$exposedVersion")

implementation("org.postgresql:postgresql:$postgres_version")
implementation("org.postgresql:postgresql:$postgresVersion")

implementation("com.zaxxer:HikariCP:$hikari_version")
implementation("com.zaxxer:HikariCP:$hikariVersion")

implementation("org.flywaydb:flyway-core:$flyway_version")
implementation("org.flywaydb:flyway-core:$flywayVersion")

testImplementation("io.ktor:ktor-server-test-host:$ktor_version")
testImplementation("io.ktor:ktor-server-test-host:$ktorVersion")

testImplementation("io.kotest:kotest-assertions-core:$kotest_version")
testImplementation("io.kotest:kotest-assertions-core:$kotestVersion")

testImplementation("org.jetbrains.kotlin:kotlin-test:1.9.20")
}
Expand All @@ -76,8 +76,8 @@ tasks.withType<Jar> {
manifest {
attributes(
mapOf(
"Main-Class" to application.mainClass
)
"Main-Class" to application.mainClass,
),
)
}
}
Expand Down
14 changes: 7 additions & 7 deletions backend/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ktor_version=2.3.7
logback_version=1.4.14
exposed_version=0.45.0
postgres_version=42.7.1
hikari_version=5.1.0
kotest_version=5.8.0
flyway_version=9.22.3
ktorVersion=2.3.7
logbackVersion=1.4.14
exposedVersion=0.45.0
postgresVersion=42.7.1
hikariVersion=5.1.0
kotestVersion=5.8.0
flywayVersion=9.22.3
kotlin.code.style=official
13 changes: 7 additions & 6 deletions backend/src/main/kotlin/no/uib/echo/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ fun Application.module() {

val mbMaxPoolSize = environment.config.propertyOrNull("ktor.maxPoolSize")?.getString()
val maybeSendGridApiKey = environment.config.propertyOrNull("ktor.sendGridApiKey")?.getString()
val sendGridApiKey = when (maybeSendGridApiKey.isNullOrEmpty()) {
true -> null
false -> maybeSendGridApiKey
}
val sendGridApiKey =
when (maybeSendGridApiKey.isNullOrEmpty()) {
true -> null
false -> maybeSendGridApiKey
}

val secret = environment.config.propertyOrNull("jwt.secret")?.getString()
val issuer = environment.config.property("jwt.issuer").getString()
Expand All @@ -51,7 +52,7 @@ fun Application.module() {
env,
migrateDb,
databaseUrl,
mbMaxPoolSize
mbMaxPoolSize,
).init()
}

Expand All @@ -65,7 +66,7 @@ fun Application.module() {
audience = audience,
issuer = issuer,
secret = secret,
jwtConfig = jwtConfig
jwtConfig = jwtConfig,
)
configureRateLimit()
if (env != Environment.PRODUCTION) configureDocs()
Expand Down
123 changes: 64 additions & 59 deletions backend/src/main/kotlin/no/uib/echo/DatabaseHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,27 @@ import java.net.URI
private const val DEFAULT_DEV_POOL_SIZE = 7
private const val DEFAULT_PROD_POOL_SIZE = 20

val tables: Array<Table> = arrayOf(
Happening,
StudentGroupHappeningRegistration,
Registration,
Answer,
SpotRange,
User,
Feedback,
StudentGroup,
StudentGroupMembership,
Reaction,
WaitingListUUID,
Whitelist
)
val tables: Array<Table> =
arrayOf(
Happening,
StudentGroupHappeningRegistration,
Registration,
Answer,
SpotRange,
User,
Feedback,
StudentGroup,
StudentGroupMembership,
Reaction,
WaitingListUUID,
Whitelist,
)

class DatabaseHandler(
private val env: Environment,
private val migrateDb: Boolean,
dbUrl: URI,
mbMaxPoolSize: String?
mbMaxPoolSize: String?,
) {
private val dbPort = if (dbUrl.port == -1) 5432 else dbUrl.port
private val dbUrlStr = "jdbc:postgresql://${dbUrl.host}:${dbPort}${dbUrl.path}"
Expand All @@ -76,7 +77,7 @@ class DatabaseHandler(
driverClassName = "org.postgresql.Driver"
connectionTimeout = 1000
maximumPoolSize = maxPoolSize
}
},
)
}

Expand All @@ -86,7 +87,7 @@ class DatabaseHandler(
GIVEN BY THE NAME OF THE SQL FILE IN src/main/resources/db/migration
WITH THE HIGHEST PREFIX. I.E., "V29__xyz_abc.sql" IS VERSION "29".
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*/
*/
private val flyway: Flyway =
Flyway.configure().baselineVersion("31").cleanDisabled(false).dataSource(dbUrlStr, dbUsername, dbPassword)
.load()
Expand Down Expand Up @@ -131,52 +132,56 @@ class DatabaseHandler(
}

private fun insertTestData() {
val happenings = listOf(
HappeningJson(
"bedriftspresentasjon-med-bekk",
"Bedpres med Bekk",
"021-05-06T16:46+01:00",
"2030-03-09T16:15+01:00",
spotRanges = listOf(
SpotRangeJson(
11,
1,
2
),
SpotRangeJson(
9,
3,
5
)
val happenings =
listOf(
HappeningJson(
"bedriftspresentasjon-med-bekk",
"Bedpres med Bekk",
"021-05-06T16:46+01:00",
"2030-03-09T16:15+01:00",
spotRanges =
listOf(
SpotRangeJson(
11,
1,
2,
),
SpotRangeJson(
9,
3,
5,
),
),
HAPPENING_TYPE.BEDPRES,
validStudentGroups[1],
),
HAPPENING_TYPE.BEDPRES,
validStudentGroups[1]
),
HappeningJson(
"fest-med-tilde",
"Fest med Tilde!",
"2021-05-06T16:46+01:00",
"2030-06-02T14:20+01:00",
spotRanges = listOf(
SpotRangeJson(
20,
1,
5
)
HappeningJson(
"fest-med-tilde",
"Fest med Tilde!",
"2021-05-06T16:46+01:00",
"2030-06-02T14:20+01:00",
spotRanges =
listOf(
SpotRangeJson(
20,
1,
5,
),
),
HAPPENING_TYPE.EVENT,
validStudentGroups[2],
),
HAPPENING_TYPE.EVENT,
validStudentGroups[2]
)
)

val adminTestUser = UserJson(
"[email protected]",
"Test McTest",
memberships = listOf("webkom"),
strikes = 0,
createdAt = DateTime.now().toString(),
modifiedAt = DateTime.now().toString()
)
val adminTestUser =
UserJson(
"[email protected]",
"Test McTest",
memberships = listOf("webkom"),
strikes = 0,
createdAt = DateTime.now().toString(),
modifiedAt = DateTime.now().toString(),
)

try {
transaction {
Expand Down
Loading

1 comment on commit 7dd8ed2

@vercel
Copy link

@vercel vercel bot commented on 7dd8ed2 Dec 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

echo-web – ./

echo-web-git-master-echo-webkom.vercel.app
echo-uib-no.vercel.app
echo-web-echo-webkom.vercel.app
echo.uib.no

Please sign in to comment.