selimatasoy / kotlin-spring-rest-api

A Modern Kotlin-Spring 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-spring-rest-api

A Modern Kotlin-Spring 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.

  • Spring Framework
  • Kotlin
  • Authorization -> JWT
  • Database -> PostgreSQL
  • ORM SQL Framework -> Exposed
  • Ktor Client -> For External API calls
  • Build Tool -> Gradle
  • Server -> Tomcat
  • API Documentation -> Swagger

Architecture

github (7)

Database Credentials

resources/application.conf

spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/$YOUR_DB_NAME"
spring.datasource.username="$YOUR_USERNAME"
spring.datasource.password="$YOUR_PASSWORD"

API Doc

- Swagger

You can access it via http://localhost:$PORT(8080 default)/swagger-ui/

Features

- Health Check

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

- 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-Spring RESTful API example. Connects to a PostgreSQL database and uses Exposed framework for database operations.


Languages

Language:Kotlin 100.0%