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)
There are multiple tags for your convenience:
blank
- contains only the workshop materialspart-N-done
- contains project code after each part is done
If you want to do this workshop from scratch - just checkout blank
, open Part 1 and enjoy. If you have questions on some steps or topics, there are multiple source links at the end of each part. I encourage you to explore those extra materials.
The Ultimate Currency converter
Let's make a backend for the ultimate currency conversion 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.
Pull requests are welcome and will be appreciated, especially in JavaScript and TypeScript parts.
Due to rigid structure of git tree, all PRs will be integrated and squashed. Contributors will be credited in README
separately.