@discue/idempotent-firebase-functions
v0.2.0
Published
Implementation of idempotent functions for firebase to prevent duplicate execution of events.
Downloads
5
Maintainers
Readme
idempotent-firebase-functions
Because firebase does not guarentee firestore events get triggered only once, we need to ensure idempotency ourselves. This module provides helper functions to create idempotent functions easily.
Components
Example
Examples
import { onDocumentWritten } from 'firebase-functions/v2/firestore';
import { idempotentFunction } from '@discue/idempotent-firebase-functions';
import handler from './handler.js'
const DOCUMENT_PATH = 'api_clients/{apiClientId}/queues/{queueId}/messages/{messageId}'
// handler function will only be called once per firebase event id
// effectively making it an idempotent function
export const written = onDocumentWritten(DOCUMENT_PATH, idempotentFunction(handler))
Installation
npm install @discue/idempotent-firebase-functions
Run E2E Tests
To run tests, run the following command
./test-e2e.sh