Skip to content

Conversation

e5l
Copy link
Member

@e5l e5l commented Jan 9, 2025

No description provided.

(cherry picked from commit 413d935ca199216a3885df36fe1f5f48dac9329b)
(cherry picked from commit 69c025dafbb59a3f91e1ca3eadd382b6bf74df22)
@e5l e5l requested review from osipxd and bjhham January 9, 2025 12:17
@e5l e5l self-assigned this Jan 9, 2025
Copy link
Member

@osipxd osipxd left a comment

Choose a reason for hiding this comment

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

Great idea to have starters! I have some comments

Comment on lines +12 to +20
// installExposed(
// JdbcConfiguration(
// url = "jdbc:postgresql://localhost:5432/ktor-sample",
// username = "ktor-sample",
// password = "ktor-sample"
// )
// ) {
// createSchema(UserEntity)
// }
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a description why this code is commented out?

Comment on lines +1 to +5
plugins {
id("ktor-sample.kotlin-jvm")


}
Copy link
Member

Choose a reason for hiding this comment

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

Nit

Suggested change
plugins {
id("ktor-sample.kotlin-jvm")
}
plugins {
id("ktor-sample.kotlin-jvm")
}

dependencies {
api(libs.ktor.server.core)
api(libs.ktor.serialization.kotlinx.json)
api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")
Copy link
Member

Choose a reason for hiding this comment

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

Move to the version catalog?

@@ -0,0 +1,17 @@
plugins {
id("ktor-sample.kotlin-jvm")
Copy link
Member

Choose a reason for hiding this comment

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

It is a bit weird that this module is called starter-ktor-web, but it is a JVM module. Am I missing something?

Copy link

@bjhham bjhham left a comment

Choose a reason for hiding this comment

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

I'm not so sure about the structure of this project - users won't be able to download a folder and run it as a standalone project, and introducing more starters would require some structural changes. It may be better to just introduce samples like this as plugins in the registry now that we have multi-module layouts, though it depends on how complex you want to make it.

dependencies {
api(libs.ktor.server.core)
api(libs.ktor.serialization.kotlinx.json)
api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")
Copy link

Choose a reason for hiding this comment

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

Looks like a duplicate here.

Comment on lines +10 to +12
class CrudRepository<E : CrudTable<E, M>, M>(
private val table: CrudTable<E, M>
) {
Copy link

Choose a reason for hiding this comment

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

Would be good to introduce an interface so we don't overexpose Exposed and can introduce new abstractions. There's also a small problem with only allowing integer ID's here.

My implementation in the chat app covers some of this:
Class: ExposedRepository.kt
Implementation: Repository.kt

I also used Database as a dependency so you can have more flexibility in your connections. I noticed the current implementation here requires static configuration.

Copy link
Member Author

Choose a reason for hiding this comment

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

Could you help me updating this starter with structure from the chat application? So we can use a starter for the chat sample

Comment on lines +9 to +12
fun Application.installExposed(
databaseConfiguration: DatabaseConfiguration,
exposedConfiguration: ExposedConfiguration.() -> Unit
) {
Copy link

Choose a reason for hiding this comment

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

I don't really like how it's mixing Application and static scopes here. We ought to be using an application attribute here for the database instance.

import io.ktor.server.routing.*
import io.ktor.starter.exposed.*

fun Application.configureRoutes() {
Copy link

Choose a reason for hiding this comment

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

Would be nice to include some rudimentary authentication in the sample application, with some admin user seeded in the newly created table. Maybe a protected todo list endpoint as well to show some code re-use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants