Skip to content

Ktor Plugin to simplify connecting ktor to firebase admin

License

Notifications You must be signed in to change notification settings

kylixeza/firetor

Repository files navigation

License

Firetor

Firetor is Ktor plugin to help you simplified connecting to firebase admin

Dependency

Firetor was distributed through jitpack and this sample is using gradle.kts file.

Configured this code in build.gradle.kts

repositories {
    ...
    maven("https://jitpack.io")
}
dependencies {
    ...
    implementation("com.github.KylixEza:firetor:$firetor_version")
}

firetor_version depends on released tag, you can check released tag in jitpack banner above.

Setup

This is some steps to configure Firetor:

  • Go to your firebase console
  • Create new project
  • Go to project dashboard and choose Project Settings
  • Choose Service accounts tab and click button Generate new private key
  • Save admin key into proper folder
  • Moved that admin key to resource folder in your Ktor Project
  • Create new Kotlin file in plugins package named Firetor

Firetor.kt

fun Application.configureFiretor() {
    install(Firetor) {
        setAdminKey("your-admin-key-file-name.json")
        setBasicConfiguration {
            //Setup other Firebase Options configuration manually
        }
    }
}
Function Parameters Parameter Type Example Mandatory
setAdminKey() fileName String "firetor-sample-admin-key.json" Yes
enableFirebaseStorage() bucketUrl String "firetor-sample.appspot.com" No
setBasicConfiguration() config FirbaseOptions.Builder.() -> FirebaseOptions.Builder? this.setConnectTimeout(10000).setDatabaseUrl("https://firetor.firebaseio.com").setReadTimeout(10000) No

Application.kt

fun main() {
    ...
}

fun Application.module() {
    ...
    configureFiretor()
}

Firetor still has access to configure other firebase options such as setDatabaseUrl, setThreadManager, setGoogleCredendtials, etc. But you need to setup that manually through setBasicConfiguration() function and you can write your own code as stated in firebase's documentation

Features

Contributing

Please fork this repository and contribute back using pull request.

Any contributions, large or small, major features, bug fixes, are welcomed and appreciated but will be thoroughly reviewed .

Contact

kylix-eza-saputra-1bb1b7192 k_ylix #Kylix3272

Don't forget to ⭐ this repository to motivates me to share more open source library