The HandlerBuilder class facilitates the writing of functions by developers building Firebase Extensions as well as developers who want to use the gcloud CLI or Google Cloud Console to deploy their functions.

Do not use HandlerBuilder when writing normal functions for deployment via the Firebase CLI. For normal purposes, use FunctionBuilder.

Index

Constructors

constructor

Accessors

analytics

  • get analytics(): { event: any }
  • Create a handler for Google Analytics events.

    event.onLog handles the logging of Analytics conversion events.

    example
    exports.myFunction = functions.handler.analytics.event.onLog((event) => { ... })

    Returns { event: any }

    • event:

auth

  • get auth(): { user: any }
  • Create a handler for Firebase Authentication events.

    user.onCreate handles the creation of users.

    example
    exports.myFunction = functions.handler.auth.user.onCreate((user) => { ... })

    user.onDelete handles the deletion of users.

    example
    exports.myFunction = functions.handler.auth.user.onDelete((user => { ... })

    Returns { user: any }

    • user:

database

  • get database(): { ref: any }
  • Create a handler for Firebase Realtime Database events.

    ref.onCreate handles the creation of new data.

    example
    exports.myFunction = functions.handler.database.ref.onCreate((snap, context) => { ... })

    ref.onUpdate handles updates to existing data.

    example
    exports.myFunction = functions.handler.database.ref.onUpdate((change, context) => { ... })

    ref.onDelete handles the deletion of existing data.

    example
    exports.myFunction = functions.handler.database.ref.onDelete((snap, context) => { ... })

    ref.onWrite handles the creation, update, or deletion of data.

    example
    exports.myFunction = functions.handler.database.ref.onWrite((change, context) => { ... })

    Returns { ref: any }

    • ref:

firestore

  • get firestore(): { document: any }
  • Create a handler for Cloud Firestore events.

    document.onCreate handles the creation of new documents.

    example
    exports.myFunction = functions.handler.firestore.document.onCreate((snap, context) => { ... })

    document.onUpdate handles updates to existing documents.

    example
    exports.myFunction = functions.handler.firestore.document.onUpdate((change, context) => { ... })

    document.onDelete handles the deletion of existing documents.

    example
    exports.myFunction = functions.handler.firestore.document.onDelete((snap, context) =>
    { ... })

    document.onWrite handles the creation, update, or deletion of documents.

    example
    exports.myFunction = functions.handler.firestore.document.onWrite((change, context) =>
    { ... })

    Returns { document: any }

    • document:

https

  • get https(): { onCall: any; onRequest: any }
  • Create a handler for HTTPS events.

    onRequest handles an HTTPS request and has the same signature as an Express app.

    example
    exports.myFunction = functions.handler.https.onRequest((req, res) => { ... })

    onCall declares a callable function for clients to call using a Firebase SDK.

    example
    exports.myFunction = functions.handler.https.onCall((data, context) => { ... })

    Returns { onCall: any; onRequest: any }

    • onCall: function
    • onRequest: function
      • onRequest(handler: (req: express.Request, resp: express.Response) => void): HttpsFunction
      • Parameters

        • handler: (req: express.Request, resp: express.Response) => void
            • (req: express.Request, resp: express.Response): void
            • Parameters

              • req: express.Request
              • resp: express.Response

              Returns void

        Returns HttpsFunction

pubsub

  • get pubsub(): { schedule: any; topic: any }
  • Create a handler for Cloud Pub/Sub events.

    topic.onPublish handles messages published to a Pub/Sub topic from SDKs, Cloud Console, or gcloud CLI.

    example
    exports.myFunction = functions.handler.pubsub.topic.onPublish((message) => { ... })

    schedule.onPublish handles messages published to a Pub/Sub topic on a schedule.

    example
    exports.myFunction = functions.handler.pubsub.schedule.onPublish((message) => { ... })

    Returns { schedule: any; topic: any }

    • schedule:
    • topic:

remoteConfig

  • get remoteConfig(): { onUpdate: any }

storage

  • get storage(): { bucket: any; object: any }
  • Create a handler for Cloud Storage for Firebase events.

    object.onArchive handles the archiving of Storage objects.

    example
    exports.myFunction = functions.handler.storage.object.onArchive((object) => { ... })

    object.onDelete handles the deletion of Storage objects.

    example
    exports.myFunction = functions.handler.storage.object.onDelete((object) => { ... })

    object.onFinalize handles the creation of Storage objects.

    example
    exports.myFunction = functions.handler.storage.object.onFinalize((object) =>
    { ... })

    object.onMetadataUpdate handles changes to the metadata of existing Storage objects.

    example
    exports.myFunction = functions.handler.storage.object.onMetadataUpdate((object) =>
    { ... })

    Returns { bucket: any; object: any }

    • bucket:
    • object:

testLab

  • get testLab(): { testMatrix: any }
  • Create a handler for Firebase Test Lab events.

    testMatrix.onComplete handles the completion of a test matrix.

    example
    exports.myFunction = functions.handler.testLab.testMatrix.onComplete((testMatrix) => { ... })

    Returns { testMatrix: any }

    • testMatrix: