Let wrap the firebase admin to work perfectly with Kotlin
This project still in development process but you can check the depedencies here
repositories {
...
maven { url 'https://jitpack.io' }
}
dependencies {
...
implementation "com.github.theerasan:kotlin-firebase-interface:version"
}
Implement Express interface
class ExpressImpl : Express {
override val express: dynamic
get() = require("express")
override val api: ExpressApp
get() = express().unsafeCast<ExpressApp>()
}
Implement Firebase App interface
class FirebassAppImpl : FirebaseApp {
override val admin = require("firebase-admin").unsafeCast<Admin>()
override val functions = require("firebase-functions")
override val config: Config = functions.config().unsafeCast<Config>()
override val https: Https = functions.https.unsafeCast<Https>()
override val database: Database
get() = admin.asDynamic().database().unsafeCast<Database>()
override val functionsDatabase = functions.database.unsafeCast<Database>()
override val firestore: Firestore
get() = admin.asDynamic().firestore().unsafeCast<Firestore>()
override val auth: Auth
get() = admin.asDynamic().auth().unsafeCast<Auth>()
}
Your Index.kt file
val firebaseApp = FirebassAppImpl()
val admin = firebaseApp.admin
val config = firebaseApp.config
admin.initializeApp(config.firebase)
val database = firebaseApp.database
val express = ExpressImpl()
val api = express.api
- Stable enough.
- Make sure you install npm first read more
- Install dependency in the project
$ npm install
- Install dependency in functions
$ cd functions
functions $ npm install
functions $ cd ..
$
$ firebase serve
Not taking so long, the local url of your services will show up in your terminal. Click the url for ex. http://localhost:5000/kotlin-firebase-interface/us-central1/helloWorld You'll see your functions work here.
- firestore
- database
- functions
- storage
- admin
- express only handle https request
- Realtime Database triggers
- Cloud Firestore triggers
- GeoPoint for Firestore
- Realtime Database Query
- Firestore Query