This repository is a use-case of the following steps:
Create a server-app on Heroku:
When logged, click on "Create a new app..."
Set the remote repository for the project:
$ heroku git:remote -a name-of-the-heroku-app
Create a database and a user database on mLab:
Get the MongoDB URI on database's dashboard, then set the keys in MongoDb.kt
of the project:
private const val DB_USER = ""
private const val DB_PASS = ""
private const val DB_NAME = ""
private const val DB_URI = "mongodb://$DB_USER:[email protected]:00000/$DB_NAME"
Mongo will automatically create the custom models (see PilotModel and CarModel).
BaseRoute for generics routes, PilotRoute and CarRoute for specific ones.
get("") { req, res -> }
get("/:id") { req, res -> }
post("") { req, res -> }
put("/:id") { req, res -> }
delete("/:id") { req, res -> }
BaseDAO for main requests. Particular requests from PilotDao or CarDao.
fun getAll(): String = getCollection().find().into(mutableListOf<T>()).toJson()
fun get(id: String): String = getCollection().findOneById(ObjectId(id)).toJson()
Dr. Emmett Brown and Marty McFly are trapped in time.
They should go to the cloud to restart the DeLorean and get back to their timeline.
Will they succeed to easily create a server using Heroku, mLab, Spark and KMongo to go back home?
dependencies {
compile 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.11'
compile 'com.sparkjava:spark-kotlin:1.0.0-alpha'
compile 'org.slf4j:slf4j-simple:1.7.12' // logger for Spark
compile 'org.litote.kmongo:kmongo:3.9.0'
compile 'com.google.code.gson:gson:2.2.4'
}