theerasan/kotlin-firebase-interface


Let wrap the firebase admin to work perfectly with Kotlin

Download


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"]]
        
        

Readme


Kotlin-Firebase-Interface

Let wrap the firebase admin to work perfectly with Kotlin

Developer description

This project still in development process but you can check the depedencies here

Install

repositories {
   ...
   maven { url 'https://jitpack.io' }
}

dependencies {
   ...
   implementation "com.github.theerasan:kotlin-firebase-interface:version"
}

Get start

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

Latest version 1.0.2

  • Stable enough.

Contributor description

Installation

  • 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 ..
$

Run your functions on local environment

$ 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.

Implementing the interface (version 1.0.0)