/microservice-boilerplate-kotlin

A microservice boilerplate written in Kotlin

Primary LanguageKotlinMIT LicenseMIT

microservice-kotlin-boilerplate

Code Style MIT

Requirements

  • Gradle
  • Kotlin
  • Docker

Settings variables

Name Description
HTTP_HOST default 0.0.0.0
HTTP_PORT default 8080
DATABASE_NAME
DATABASE_HOST default 0.0.0.0
DATABASE_PASSWORD
DATABASE_USER

Build

./gradlew clean build

Test

Unit Tests

./gradlew test

Run

  1. Build the docker image
    docker build . -t microservice-kotlin-boilerplate
    
  2. Run the image
    docker run -p 8080:8080 microservice-kotlin-boilerplate
    

Coding Style

Use Google Style for the coding style guide.
Use ktlint to check style.

Install

brew install shyiko/ktlint/ktlint

Apply ktlint to IDEA built-in formatter (optional): ktlint --apply-to-idea

Create Release

To create a release which will be deployed to production follow the following steps:

  • on master branch, create tag

    git tag -a fix-v1.0.3 -m 'fix: issue#100'
    git push origin refs/tags/fix-v1.0.3
    
  • use git-chglog to generate the changelog

    git-chglog 1.0.0..2.0.0
    

    copy this content to CHANGELOG.md

  • create new release in GitHub and copy generated changelog for the tag to notes

API

  • url: /api/example/{id}
  • method: GET
  • description:
  • query parameters:
    • {id}: int, id
  • return on success: example
    {
        "example": 3
    }
  • return on error: (i.e. 400 error)
    {
      "error": "id parameter not provided"
    }
  • return on error: internal server error (i.e. 500 error)
    {
      "error": "server error"
    }

License

Licensed under MIT.