LDuncAndroid / kotlin-ktor-rest-api

A Modern Kotlin-Ktor RESTful API example. Connects to a PostgreSQL database and uses Exposed framework for database operations.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 feature 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
  • API Documentation -> NOT YET IMPLEMENTED!

Architecture

github (6)

Database Credentials

resources/application.conf

    database {
        exampleDatabaseUrl="jdbc:postgresql://localhost:5432/$YOUR_DB_NAME"
        exampleDatabaseDriver="org.postgresql.Driver"
        exampleDatabaseUser="$YOUR_USERNAME"
        exampleDatabasePassword="$YOUR_PASSWORD"
    }

Features

- Health Check

GET /public-api/v1/healthCheck
  Just returns a simple object

- Authentication

POST /public-api/v1/authentication/createUser
  Registers a user to the db
POST /public-api/v1/authentication/login
  Returns a jwt token if success
GET /api/v1/authentication/userInfo (Needs Authorization token from login as Authorization header : "Bearer {$token}")
  Returns the user information

- Star Wars

GET /api/v1/star-wars/movie (Needs Authorization token from login as Authorization header : "Bearer {$token}")
  An External API call example. Returns a movie information from an external api

About

A Modern Kotlin-Ktor RESTful API example. Connects to a PostgreSQL database and uses Exposed framework for database operations.


Languages

Language:Kotlin 100.0%