Kotlin + Node.js example

Kotlin + Node.js example

- 1 min

Source Code: https://github.com/miquelbeltran/kotlin-node.js

This project contains a Node.js application implemented in Kotlin 1.1.

It uses Express and Request Node libraries to implement a REST API that retreives data from Amazon, while using the Kotlin standard library.

This project is part this blog post: Your first Node.js app with Kotlin.

Code Sample

external fun require(module:String):dynamic

fun main(args: Array<String>) {
println("Hello JavaScript!")

val express = require("express")
val app = express()
val amazon = Amazon()

app.get("/", { req, res ->
res.type("text/plain")
res.send("i am a beautiful butterfly")
})
app.get("/amazon/:asin", { req, res ->
res.type("text/plain")
amazon.getAmazonPrice(req.params.asin) {
res.send("Price is $it")
}
})
app.listen(3000, {
println("Listening on port 3000")
})
}
Miquel Beltran

Miquel Beltran

Software engineer, Android specialist and newbie mentor

rss facebook twitter github youtube mail spotify instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora