Skip to content

Cloud Functions example apps

A runnable firebase-functions/v2 bundle that runs on Nimbus without changing its imports. HTTP and callable exports serve from the main Nimbus port, and Firestore document triggers get at-least-once delivery with durable retry. Read the overview first if you have not run a functions bundle on Nimbus yet.

The example lives under examples/cloud-functions/ in the source repository. Run it in place from a checkout.

Terminal window
nimbus dev
nimbus deploy [TARGET]

Run from the example directory. TARGET is a URL or a configured target name; omit it to target your local server. Nimbus generates the functions bundle under .nimbus/firebase/.

Tasks reacts to the shared tasks collection and exposes a plain HTTP handler:

  • deriveTask is an onDocumentCreated trigger. When a task document is inserted, it writes a derived record to taskDerivations.
  • taskDetails is an HTTP handler. It reads a task and its derived record by id and returns their current fields as JSON.

Once a task exists, call the HTTP export on the main Nimbus port:

Terminal window
curl "http://localhost:8080/taskDetails?taskId=TASK_DOCUMENT_ID"

Cloud Functions is handler code, not a task data client, so this surface implements the tasks spec through a trigger rather than through create/read/update/delete calls. The observable behavior is a derived write that appears after a task is created, not a client subscription.

Nimbus delivers Firestore triggers at least once, so the trigger is written to be idempotent: the derived document uses the source task’s id as its own id and set() writes the complete value, so a retry overwrites the same document instead of duplicating it or double-counting.