In this workshop we will explore what Firebase Functions are and setup project for writing these functions in Kotlin. To get there we will touch some other interesting topics like Firebase Realtime Database and TypeScript.
- Firebase account
- Editor for JavaScript/TypeScript (my choice is VS Code)
- IntelliJ Idea (Community edition is sufficient)
The Ultimate Currency converter
Let's make a backend for the ultimate currency convertion app - a user enters the price in euro and the backend converts it to other currencies.
The backend will work as follows:
- The client app pushes a new "conversion" object with a euro value into
conversions
table - A function gets triggered and picks up this object and calculates values in all other currencies
- Data gets written back to the same object with a timestamp
Firebase Realtime Database structure:
{
"rates" : {
"usd" : 1.175,
"czk" : 25.88,
"pln" : 4.303,
"rub" : 68.52
},
"conversions" : {
"<hash1>" : {
"eur" : 3.0
},
"<hash2>" : {
"timestamp" : 1507570800,
"eur" : 1.0,
"usd" : 1.175,
"czk" : 25.88,
"pln" : 4.303,
"rub" : 68.52
}
}
}
- Part 1 - A basic project setup
- Part 2 - Sprinkle in some types
- Part 3 - Hello Kotlin
- Part 4 - Even more Kotlin
- Optional - A bit of auto-magic
I am not a JavaScript expert, therefore the JS code here is far from optimal. Apologies to JS fans or experts that get eye-bleeds.