Ktor codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.
This codebase was created to demonstrate a fully fledged fullstack application built with Ktor including CRUD operations, authentication, routing, pagination, and more. We've gone to great lengths to adhere to the Ktor community styleguides & best practices. For more information on how to this works with other frontends/backends, head over to the RealWorld repo!!
As above logo shows, it works mainly with four kotlin based frameworks/libraries. That is ..
Ktor
- web server(netty)Exposed
- kotlin native ormKoin
- for dependency injectionKotest
- kotlin native test (supports property test)
This is my first project with above frameworks. I think there exists small amount of reference to find out the Best Practice to create web server in ktor. I will try my best to find out my own "Best Practice" in this project.
- Cleanup
/build.gradle.kts
withbuildSrc
Password
withPasswordDelegate
- it is my first time to apply what is called delegate property. It could probably get better... but I'm really satisfied with that
- Test
- kotest is super awesome!
- It provides nice dsl for assertions & property testing.
- It also supports integration with a lot of other projects - ktor/koin/konform!
- IDE/plugin support is quite bad for now. It think will be better soon.
- Kotlin Experimental Features!
- context receiver is still experimental feature in kotlin
- with context-receiver, we can provide much more expressiveness code!
- see my use cases!
- integrationTest works with
HttpClientContext
! - authenticatedGet works with
AuthenticatedUserContext
! we don't need to provide boilerplatecall.userId()
stuff every time!
- integrationTest works with
- I think that ktor/exposed support light weight server. So, I wonder is it worth enough to consist on DI or clean architecture pattern
that I used to studied in the
Spring Framework
. Well that must be case by case. In this case I ommited lots of those values and focus on framwork/library usages
Current Test with postman - with script provided @here
Endpoints - See Details @here
- Authentication
- Registration
- Get Current User
- Update User
- Get Profile
- Follow user
- Unfollow user
- List Articles
- Get Article - no test yet
- Create Article
- Update Article
- Delete Article
- Add Comments to an Article
- Get Comments from an Article
- Delete Comment
- Favorite Article
- Unfavorite Article
- Get Tags
- Feed Articles (a.k.a. filter)
./gradlew build
./gradlew run