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.
Run the example
Section titled “Run the example”nimbus devnimbus 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/.
The app
Section titled “The app”Tasks
reacts to the shared tasks collection and exposes a plain HTTP handler:
deriveTaskis anonDocumentCreatedtrigger. When a task document is inserted, it writes a derived record totaskDerivations.taskDetailsis 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:
curl "http://localhost:8080/taskDetails?taskId=TASK_DOCUMENT_ID"A trigger, not a CRUD client
Section titled “A trigger, not a CRUD client”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.