Skip to content

Commit 80135f6

Browse files
authored
Upgraded project to latest versions (#19)
* Upgraded project to latests versions * new version 2.2.0 * corrected desktop dependency * corrected Backend queries * corrected Ktlint issue * corrected Ktlint issue * corrected Ktlint issue * corrected Ktlint issue * corrected Ktlint issue * corrected Ktlint issue * corrected Ktlint issue * corrected Ktlint issue * corrected Ktlint issue * corrected Ktlint issue * corrected Ktlint issue
1 parent f84f091 commit 80135f6

File tree

94 files changed

+1138
-962
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1138
-962
lines changed

backend/.run/Adoptme [desktopRun].run.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<component name="ProjectRunConfigurationManager">
22
<configuration default="false" name="Adoptme [desktopRun]" type="GradleRunConfiguration" factoryName="Gradle" nameIsGenerated="true">
33
<ExternalSystemSettings>
4+
<option name="env">
5+
<map>
6+
<entry key="DEVELOPER_DIR" value="/Applications/Xcode.app/Contents/Developer" />
7+
</map>
8+
</option>
49
<option name="executionName" />
510
<option name="externalProjectPath" value="$PROJECT_DIR$" />
611
<option name="externalSystemIdString" value="GRADLE" />

backend/.run/Server.run.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<ExternalSystemSettings>
44
<option name="env">
55
<map>
6+
<entry key="DEVELOPER_DIR" value="/Applications/Xcode.app/Contents/Developer" />
67
<entry key="JDBC_DATABASE_URL" value="jdbc:postgresql:habits?user=postgres" />
78
<entry key="JDBC_DRIVER" value="org.postgresql.Driver" />
89
<entry key="JWT_SECRET" value="898748674728934843" />
@@ -26,6 +27,7 @@
2627
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
2728
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
2829
<DebugAllEnabled>false</DebugAllEnabled>
30+
<RunAsTest>false</RunAsTest>
2931
<method v="2" />
3032
</configuration>
3133
</component>

backend/docs/.swagger-codegen/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.41
1+
3.0.69

backend/docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2140,7 +2140,7 @@ <h3> Status: 200 - A JSON array of user names </h3>
21402140
this.isPrimitive = !this.isAny && !this.isArray && !this.isObject;
21412141

21422142
//
2143-
this.showToggle = this.schema.description || this.schema.title || this.isPrimitive && (this.schema.minimum || this.schema.maximum || this.schema.exclusiveMinimum || this.schema.exclusiveMaximum);
2143+
this.showToggle = this.schema.description || this.schema.title || this.isPrimitive && (this.schema.minimum || this.schema.maximum || this.schema.exclusiveMinimum || this.schema.exclusiveMaximum || this.schema.maxLength || this.schema.minLength || this.schema.pattern || this.schema.format);
21442144

21452145
// populate isRequired property down to properties
21462146
if (this.schema && Array.isArray(this.schema.required)) {

backend/src/main/kotlin/com/multiplatformkickstarter/GeneralRoutingConfig.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@ fun Application.configureGeneralRouting() {
4444
}
4545

4646
class AuthenticationException : RuntimeException()
47+
4748
class AuthorizationException : RuntimeException()

backend/src/main/kotlin/com/multiplatformkickstarter/auth/JwtService.kt

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,24 @@ import java.util.Date
99
const val JWT_CONFIGURATION = "MyProjectNameJWT"
1010

1111
class JwtService {
12-
1312
private val issuer = "MyProjectNameServer"
1413
private val jwtSecret = System.getenv("JWT_SECRET")
1514
private val algorithm = HMAC512(jwtSecret)
1615

17-
val verifier: JWTVerifier = JWT
18-
.require(algorithm)
19-
.withIssuer(issuer)
20-
.build()
16+
val verifier: JWTVerifier =
17+
JWT
18+
.require(algorithm)
19+
.withIssuer(issuer)
20+
.build()
2121

22-
fun generateToken(databaseUser: DatabaseUser): String = JWT.create()
23-
.withSubject("Authentication")
24-
.withIssuer(issuer)
25-
.withClaim("id", databaseUser.userId)
26-
.withExpiresAt(expiresAt())
27-
.sign(algorithm)
22+
fun generateToken(databaseUser: DatabaseUser): String =
23+
JWT
24+
.create()
25+
.withSubject("Authentication")
26+
.withIssuer(issuer)
27+
.withClaim("id", databaseUser.userId)
28+
.withExpiresAt(expiresAt())
29+
.sign(algorithm)
2830

2931
@Suppress("MagicNumber")
3032
private fun expiresAt() = Date(System.currentTimeMillis() + 3_600_000 * 24) // 24 hours

backend/src/main/kotlin/com/multiplatformkickstarter/models/DatabaseUser.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ data class DatabaseUser(
88
val userId: Int,
99
val email: String,
1010
val name: String,
11-
val passwordHash: String
11+
val passwordHash: String,
1212
) : Serializable, Principal

backend/src/main/kotlin/com/multiplatformkickstarter/plugins/HTTP.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ fun Application.configureHTTP() {
2424
install(CachingHeaders) {
2525
options { _, outgoingContent ->
2626
when (outgoingContent.contentType?.withoutParameters()) {
27-
ContentType.Text.CSS -> CachingOptions(
28-
CacheControl.MaxAge(maxAgeSeconds = 24 * 60 * 60),
29-
ZonedDateTime.of(0, 0, 1, 0, 0, 0, 0, ZoneId.systemDefault())
30-
)
27+
ContentType.Text.CSS ->
28+
CachingOptions(
29+
CacheControl.MaxAge(maxAgeSeconds = 24 * 60 * 60),
30+
ZonedDateTime.of(0, 0, 1, 0, 0, 0, 0, ZoneId.systemDefault()),
31+
)
32+
3133
else -> null
3234
}
3335
}

backend/src/main/kotlin/com/multiplatformkickstarter/repository/pets/PetsRepository.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface PetsRepository {
1717
size: String,
1818
color: String,
1919
status: String,
20-
shelterId: Int?
20+
shelterId: Int?,
2121
): PetModel?
2222

2323
suspend fun getPet(petId: Int): PetModel
@@ -39,6 +39,6 @@ interface PetsRepository {
3939
size: String?,
4040
color: String?,
4141
status: String?,
42-
shelterId: Int?
42+
shelterId: Int?,
4343
): PetModel?
4444
}

backend/src/main/kotlin/com/multiplatformkickstarter/repository/pets/PetsRepositoryImp.kt

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import org.jetbrains.exposed.sql.ResultRow
1212
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
1313
import org.jetbrains.exposed.sql.deleteWhere
1414
import org.jetbrains.exposed.sql.insert
15-
import org.jetbrains.exposed.sql.select
1615
import org.jetbrains.exposed.sql.statements.InsertStatement
1716
import org.jetbrains.exposed.sql.update
1817

@@ -31,43 +30,41 @@ class PetsRepositoryImp : PetsRepository {
3130
size: String,
3231
color: String,
3332
status: String,
34-
shelterId: Int?
33+
shelterId: Int?,
3534
): PetModel? {
3635
var statement: InsertStatement<Number>? = null
3736
dbQuery {
38-
statement = Pets.insert {
39-
it[Pets.userId] = userId
40-
it[Pets.title] = title
41-
it[Pets.description] = description
42-
it[Pets.images] = images
43-
it[Pets.category] = category
44-
it[Pets.location] = location
45-
it[Pets.published] = published
46-
it[Pets.breed] = breed
47-
it[Pets.age] = age
48-
it[Pets.gender] = gender
49-
it[Pets.size] = size
50-
it[Pets.color] = color
51-
it[Pets.status] = status
52-
it[Pets.shelterId] = shelterId ?: 0
53-
}
37+
statement =
38+
Pets.insert {
39+
it[Pets.userId] = userId
40+
it[Pets.title] = title
41+
it[Pets.description] = description
42+
it[Pets.images] = images
43+
it[Pets.category] = category
44+
it[Pets.location] = location
45+
it[Pets.published] = published
46+
it[Pets.breed] = breed
47+
it[Pets.age] = age
48+
it[Pets.gender] = gender
49+
it[Pets.size] = size
50+
it[Pets.color] = color
51+
it[Pets.status] = status
52+
it[Pets.shelterId] = shelterId ?: 0
53+
}
5454
}
5555
return rowToPetModel(statement?.resultedValues?.get(0))
5656
}
5757

5858
override suspend fun getPets(userId: Int): List<PetModel> {
5959
return dbQuery {
60-
Pets.select {
61-
Pets.userId.eq((userId)) // 3
62-
}.mapNotNull { rowToPetModel(it) }
60+
Pets.select(Pets.userId).where { Pets.userId.eq(userId) }
61+
.mapNotNull { rowToPetModel(it) }
6362
}
6463
}
6564

6665
override suspend fun getPet(petId: Int): PetModel {
6766
return dbQuery {
68-
Pets.select {
69-
Pets.id.eq((petId))
70-
}.mapNotNull { rowToPetModel(it) }
67+
Pets.select(Pets.id).where { Pets.id.eq(petId) }.mapNotNull { rowToPetModel(it) }
7168
}.first()
7269
}
7370

@@ -92,10 +89,10 @@ class PetsRepositoryImp : PetsRepository {
9289
size: String?,
9390
color: String?,
9491
status: String?,
95-
shelterId: Int?
92+
shelterId: Int?,
9693
): PetModel? {
9794
return dbQuery {
98-
Pets.select {
95+
Pets.select(Pets.id).where {
9996
Pets.id.eq((petId))
10097
}.forUpdate()
10198

@@ -139,7 +136,7 @@ class PetsRepositoryImp : PetsRepository {
139136
}
140137
}
141138

142-
Pets.select {
139+
Pets.select(Pets.id).where {
143140
Pets.id.eq((petId))
144141
}.mapNotNull { rowToPetModel(it) }
145142
}.firstOrNull()
@@ -166,7 +163,7 @@ class PetsRepositoryImp : PetsRepository {
166163
size = PetSize.valueOf(row[Pets.size]),
167164
color = row[Pets.color].toString(),
168165
status = PetStatus.valueOf(row[Pets.status]),
169-
shelterId = row[Pets.shelterId]
166+
shelterId = row[Pets.shelterId],
170167
)
171168
}
172169

0 commit comments

Comments
 (0)