kotlin-ktor-rest-api
A Modern Kotlin-Ktor RESTful API example. Connects to a PostgreSQL database and uses Exposed framework for database operations. Focused on Clean Architecture, SOLID Principles and feautre based development.
- Ktor Framework
- Kotlin
- Dependency Injection -> Koin
- Authorization -> JWT
- Database -> PostgreSQL
- ORM SQL Framework -> Exposed
- Ktor Client -> For External API calls
- Build Tool -> Gradle
- Server -> Tomcat
Architecture
Database Creditentials
resources/application.conf
database {
exampleDatabaseUrl="jdbc:postgresql://localhost:5432/exampleDatabase"
exampleDatabaseDriver="org.postgresql.Driver"
exampleDatabaseUser="postgres"
exampleDatabasePassword="Test1234"
}
Features
- Health Check
GET /healthCheck/
Just returns a simple object
- Authentication
POST /createUser/
Registers a user to the db
POST /login/
Returns a jwt token if success
GET /userInfo/ (Needs Authroization token from login as Authorization header)
Return user information
- Star Wars
GET /movie/
An External API call example. Returns a movie information from an external api