Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.theerasan:kotlin-firebase-interface:1.0.7-alpha2'
}
dependencies {
implementation("com.github.theerasan:kotlin-firebase-interface:1.0.7-alpha2")
}
<dependency>
<groupId>com.github.theerasan</groupId>
<artifactId>kotlin-firebase-interface</artifactId>
<version>1.0.7-alpha2</version>
</dependency>
libraryDependencies += "com.github.theerasan" % "kotlin-firebase-interface" % "1.0.7-alpha2"
:dependencies [[com.github.theerasan/kotlin-firebase-interface "1.0.7-alpha2"]]
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
$ npm install
$ 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.