Giter VIP home page Giter VIP logo

ktor-koin-sample-app's Introduction

ktor-koin-sample-app

Ktor is a web application framework written in Kotlin that utilizes Coroutines to provide the fully asynchronous, non-blocking behavior. Shows usage of ktor to create a simple API to store simple todo list.

ktlint Kotlin ktor branch

Build

Building the project

./gradlew clean && ./gradlew build

Compiling the project and generating a docker image

./gradlew clean && ./gradlew build && docker build --no-cache -t crisun/ktor-koin-sample-app .

Compiling the project and generating a docker image with docker-compose

./gradlew clean && ./gradlew build && docker-compose build

Start

Using docker-compose:

docker-compose up

Using docker:

docker run --rm -it -p 8080:8080 crisun/ktor-koin-sample-app

Running manually:

java -jar ktor-koin-sample-app-1.0.0-all.jar

Examples

Start the application and call the operations:

Login to obtain jwt token:

curl -i -XPOST -H "Content-type: application/json" "http://localhost:8080/user/login" -d '{"username":"crisun","password":"r4e3w2q1"}'

List all tasks:

curl -i -H "Authorization: Bearer $TOKEN" "http://localhost:8080/todos"

Query a task:

curl -i -H "Authorization: Bearer $TOKEN" "http://localhost:8080/todo/1"

Insert task:

curl -i -XPOST -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" "http://localhost:8080/todo" -d '{"title":"Task 1","description":"Do the homework"}'

Update task:

curl -i -XPUT -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" "http://localhost:8080/todo/1" -d '{"title":"Task 1","description":"Do the homework and clean the house"}'

Delete task:

curl -i -XDELETE -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" "http://localhost:8080/todo/1"

Health check:

curl -i "http://localhost:8080/health"

Libraries

Koin: https://insert-koin.io

Flywaydb: https://flywaydb.org

Logback: http://logback.qos.ch

Spring Jdbc: https://spring.io

H2 Database: https://www.h2database.com

HikariCP: https://github.com/brettwooldridge/HikariCP

Kotlin Logging: https://github.com/MicroUtils/kotlin-logging

Ktor flyway feature: https://github.com/viartemev/ktor-flyway-feature

Ktor JWT feature: https://ktor.io/servers/features/authentication/jwt.html

ktor-koin-sample-app's People

Contributors

crisunx avatar

Stargazers

Husnu TAPAN avatar kokiTakeda avatar  avatar Gabriel Sales avatar D0Lim avatar Eric Kariuki avatar Nick Baughman avatar Antanas Sinica avatar Daniel Kouba avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.