0.10.0 ā€¢ Published 1 year ago

@schedulekit/firebase v0.10.0

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
1 year ago

Schedule Kit

šŸš§ Work in progress

Setting Up

First, follow these steps to create Cloud Tasks queue, set up and deploy schedule function:

  1. Make sure you have created a Firebase project and initialized Firebase Functions.
  2. Enable Cloud Tasks API
  3. Create a queue. Note that the queue name and the region will be required to set up the Schedule Kit.
  4. Set up and export a function.

    const functions = require("firebase-functions");
    // 1. Import the function
    const { createScheduleKit } = require("@schedulekit/firebase");
    // 2. Import firebase-admin
    const admin = require("firebase-admin");
    
    // 3. Initialize the app
    admin.initializeApp();
    
    // 4. Set up and export function
    const { processSchedule } = createScheduleKit("schedule-queue", {
      region: "asia-southeast1-a", // You can skip options if you use us-central1
    });
    export { processSchedule };
    
    exports.helloWorld = functions.https.onRequest((request, response) => {
      functions.logger.info("Hello logs!", { structuredData: true });
      response.send("Hello from Firebase!");
    });
  5. Deploy the functions

Executions recovery

Create a composite index with the given settings to enable executions recovery:

  • Collection: executions
  • Fields:
    • state: Ascending
    • startedAt: Ascending
  • Query scope: Collection group