This repository serves as a sandbox for testing Kotlin libraries, such as
- Ktor - an asynchronous application framework
- Kodein DI - a pure Kotlin dependency injection library
- Kmongo - a pure Kotlin library for work with MongoDB (can be used with both sync and async drivers)
- MongoDB - a NoSQL document-oriented database.
The application provides a RESTful API for fetching random jokes of the ever-so-popular 80-90s action star, Chuck Norris. The jokes are initially loaded from The Internet Chuck Norris Database and persisted to a local MongoDB
- Kotlin
- MongoDB server
The application, once started, can be access via http://localhost:8080.
1 - Create ADMIN user
POST http://localhost:8080/users
{
"userName": "admin",
"password": "admin",
"role": "ADMIN"
}
2 - Get auth token
POST http://localhost:8080/auth/token
{
"userName": "admin",
"password": "admin"
}
--- Response ---
{
"token": "eyJ0eXAiOiJKV1QiLCJhbGc..."
}
3 - Load database with joke data from external resource.
POST http://localhost:8080/app/init -H "Authorization: {token}"
Fetch all jokes
GET http://localhost:8080/chucknorris
Fetch joke by Id (MongoDB ObjectId)
GET http://localhost:8080/chucknorris/{id}
Fetch joke by external Id
GET http://localhost:8080/chucknorris/joke/{id}
Fetch random joke
GET http://localhost:8080/chucknorris/random
Fetch n number of random jokes
GET http://localhost:8080/chucknorris/random?quantity={n}