From aae89e522081d720484a66f87de0cb967510c11c Mon Sep 17 00:00:00 2001 From: Ace Nassri Date: Wed, 27 Jun 2018 12:48:58 -0700 Subject: [PATCH 01/15] Initial commit --- functions/README.md | 3 +++ functions/node8/index.js | 20 ++++++++++++++++++++ functions/node8/package.json | 17 +++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 functions/node8/index.js create mode 100644 functions/node8/package.json diff --git a/functions/README.md b/functions/README.md index 1e9f0890c7..a0d5ec297b 100644 --- a/functions/README.md +++ b/functions/README.md @@ -33,3 +33,6 @@ environment. * [OCR (Optical Character Recognition)](ocr/) * [SendGrid](sendgrid/) * [Slack](slack/) + +## Notes: +The samples in the `node8` directory are designed for use with Node.js `8.x.x`. Unless otherwise noted, all other samples are designed for Node.js `6.x.x`. \ No newline at end of file diff --git a/functions/node8/index.js b/functions/node8/index.js new file mode 100644 index 0000000000..0b0cbcc1d4 --- /dev/null +++ b/functions/node8/index.js @@ -0,0 +1,20 @@ +/** + * Background Cloud Function that only executes within + * a certain time period after the triggering event + * + * @param {object} event The Cloud Functions event. + * @param {function} callback The callback function. + */ +exports.avoidInfiniteRetries = async (event) => { + const eventAge = Date.now() - Date.parse(event.timestamp); + const eventMaxAge = 10000; + + // Ignore events that are too old + if (eventAge > eventMaxAge) { + console.log(`Dropping event ${event} with age ${eventAge} ms.`); + return; + } + + // Do what the function is supposed to do + console.log(`Processing event ${event} with age ${eventAge} ms.`); +}; \ No newline at end of file diff --git a/functions/node8/package.json b/functions/node8/package.json new file mode 100644 index 0000000000..1d786a3470 --- /dev/null +++ b/functions/node8/package.json @@ -0,0 +1,17 @@ +{ + "name": "nodejs-docs-samples-gcf-node8", + "version": "0.0.1", + "description": "Google Cloud Functions samples for Node.js 8", + "scripts": { + }, + "engines": { "node": "^8"}, + "repository": { + "type": "git", + "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git" + }, + "author": "Google LLC", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/GoogleCloudPlatform/nodejs-docs-samples/issues" + } +} From 27d58d5d52376c102b88b777d3326bed7b695c07 Mon Sep 17 00:00:00 2001 From: Ace Nassri Date: Wed, 27 Jun 2018 12:52:07 -0700 Subject: [PATCH 02/15] Add region tags --- functions/node8/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/functions/node8/index.js b/functions/node8/index.js index 0b0cbcc1d4..d12fa1b8f2 100644 --- a/functions/node8/index.js +++ b/functions/node8/index.js @@ -5,6 +5,8 @@ * @param {object} event The Cloud Functions event. * @param {function} callback The callback function. */ + +// [START functions_tips_retry_node8] exports.avoidInfiniteRetries = async (event) => { const eventAge = Date.now() - Date.parse(event.timestamp); const eventMaxAge = 10000; @@ -17,4 +19,5 @@ exports.avoidInfiniteRetries = async (event) => { // Do what the function is supposed to do console.log(`Processing event ${event} with age ${eventAge} ms.`); -}; \ No newline at end of file +}; +// [END functions_tips_retry_node8] From 5bc01fbf5c15132ea0a4e14b4ca387f5634e871d Mon Sep 17 00:00:00 2001 From: Ace Nassri Date: Wed, 27 Jun 2018 17:54:09 -0700 Subject: [PATCH 03/15] Fix bugs --- functions/node8/index.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/functions/node8/index.js b/functions/node8/index.js index d12fa1b8f2..0b0a393439 100644 --- a/functions/node8/index.js +++ b/functions/node8/index.js @@ -6,18 +6,30 @@ * @param {function} callback The callback function. */ -// [START functions_tips_retry_node8] -exports.avoidInfiniteRetries = async (event) => { - const eventAge = Date.now() - Date.parse(event.timestamp); +// [START functions_tips_infinite_retries_node8] +exports.avoidInfiniteRetries = async (event, context) => { + const eventAge = Date.now() - Date.parse(context.timestamp); const eventMaxAge = 10000; // Ignore events that are too old if (eventAge > eventMaxAge) { - console.log(`Dropping event ${event} with age ${eventAge} ms.`); + console.log(`Dropping event ${context.eventId} with age ${eventAge} ms.`); return; } // Do what the function is supposed to do - console.log(`Processing event ${event} with age ${eventAge} ms.`); + console.log(`Processing event ${context.eventId} with age ${eventAge} ms.`); +}; +// [END functions_tips_infinite_retries_node8] + +// [START functions_tips_retry_node8] +exports.retryPromise = async (event, context) => { + const tryAgain = !!event.attributes.retry; + + if (tryAgain) { + throw new Error(`Retrying...`); + } else { + return new Error('Not retrying...'); + } }; // [END functions_tips_retry_node8] From bbf4b21e823210e2ebeffd17fd8d1c23a3dff0aa Mon Sep 17 00:00:00 2001 From: Ace Nassri Date: Thu, 28 Jun 2018 15:06:36 -0700 Subject: [PATCH 04/15] Remove unnecessary async's --- functions/node8/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/node8/index.js b/functions/node8/index.js index 0b0a393439..641b8ffe7b 100644 --- a/functions/node8/index.js +++ b/functions/node8/index.js @@ -7,7 +7,7 @@ */ // [START functions_tips_infinite_retries_node8] -exports.avoidInfiniteRetries = async (event, context) => { +exports.avoidInfiniteRetries = (event, context) => { const eventAge = Date.now() - Date.parse(context.timestamp); const eventMaxAge = 10000; @@ -23,7 +23,7 @@ exports.avoidInfiniteRetries = async (event, context) => { // [END functions_tips_infinite_retries_node8] // [START functions_tips_retry_node8] -exports.retryPromise = async (event, context) => { +exports.retryPromise = (event, context) => { const tryAgain = !!event.attributes.retry; if (tryAgain) { From 984d23e6c989f4012372fbb78c1ca4456c167fa3 Mon Sep 17 00:00:00 2001 From: Ace Nassri Date: Fri, 29 Jun 2018 11:22:58 -0700 Subject: [PATCH 05/15] s/attrs/data/ --- functions/node8/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/node8/index.js b/functions/node8/index.js index 641b8ffe7b..47f2c9a859 100644 --- a/functions/node8/index.js +++ b/functions/node8/index.js @@ -24,7 +24,7 @@ exports.avoidInfiniteRetries = (event, context) => { // [START functions_tips_retry_node8] exports.retryPromise = (event, context) => { - const tryAgain = !!event.attributes.retry; + const tryAgain = !!event.data.retry; if (tryAgain) { throw new Error(`Retrying...`); From 50200ad510a42e760d2340154b612ea2dbc70fb5 Mon Sep 17 00:00:00 2001 From: Ace Nassri Date: Fri, 29 Jun 2018 11:48:19 -0700 Subject: [PATCH 06/15] Add comments --- functions/node8/index.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/functions/node8/index.js b/functions/node8/index.js index 47f2c9a859..86d9f2240c 100644 --- a/functions/node8/index.js +++ b/functions/node8/index.js @@ -7,7 +7,14 @@ */ // [START functions_tips_infinite_retries_node8] -exports.avoidInfiniteRetries = (event, context) => { +/** + * Background Cloud Function that only executes within + * a certain time period after the triggering event + * + * @param {object} event The Cloud Functions event. + * @param {function} context Information about the event. + */ +exports.avoidInfiniteRetries = (data, context) => { const eventAge = Date.now() - Date.parse(context.timestamp); const eventMaxAge = 10000; @@ -23,8 +30,15 @@ exports.avoidInfiniteRetries = (event, context) => { // [END functions_tips_infinite_retries_node8] // [START functions_tips_retry_node8] -exports.retryPromise = (event, context) => { - const tryAgain = !!event.data.retry; +/** + * Background Cloud Function that only executes within + * a certain time period after the triggering event + * + * @param {object} event The Cloud Functions event. + * @param {function} context Information about the event. + */ +exports.retryPromise = (data, context) => { + const tryAgain = !!data.retry; if (tryAgain) { throw new Error(`Retrying...`); From e2ca3097b469d5e8a5674983096995892d19b150 Mon Sep 17 00:00:00 2001 From: Ace Nassri Date: Mon, 2 Jul 2018 16:29:03 -0700 Subject: [PATCH 07/15] Add remaining Node8 samples --- functions/node8/index.js | 70 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/functions/node8/index.js b/functions/node8/index.js index 86d9f2240c..30366017d7 100644 --- a/functions/node8/index.js +++ b/functions/node8/index.js @@ -47,3 +47,73 @@ exports.retryPromise = (data, context) => { } }; // [END functions_tips_retry_node8] + +// [START functions_helloworld_background_node8] + +// helloBackground +// helloPubSub +// helloGCS +// helloGCSGeneric + +// [START functions_helloworld_background] +/** + * Background Cloud Function. + * + * @param {object} event Data passed to the Cloud Function. + */ +exports.helloBackground = (data) => { + return `Hello ${data.name || 'World'}!`; +}; +// [END functions_helloworld_background] + +// [START functions_helloworld_pubsub] +/** + * Background Cloud Function to be triggered by Pub/Sub. + * This function is exported by index.js, and executed when + * the trigger topic receives a message. + * + * @param {object} event The Cloud Functions event. + */ +exports.helloPubSub = (event) => { + const pubsubMessage = event.data; + const name = pubsubMessage.data ? Buffer.from(pubsubMessage.data, 'base64').toString() : 'World'; + + console.log(`Hello, ${name}!`); +}; +// [END functions_helloworld_pubsub] + +// [START functions_helloworld_storage] +/** + * Background Cloud Function to be triggered by Cloud Storage. + * + * @param {object} file The Cloud Functions event. + */ +exports.helloGCS = (file) => { + if (file.resourceState === 'not_exists') { + console.log(`File ${file.name} deleted.`); + } else if (file.metageneration === '1') { + // metageneration attribute is updated on metadata changes. + // on create value is 1 + console.log(`File ${file.name} uploaded.`); + } else { + console.log(`File ${file.name} metadata updated.`); + } +}; +// [END functions_helloworld_storage] + +// [START functions_helloworld_storage_generic] +/** + * Generic background Cloud Function to be triggered by Cloud Storage. + * + * @param {object} event The Cloud Functions event. + */ +exports.helloGCSGeneric = (file, context) => { + console.log(` Event ${context.eventId}`); + console.log(` Event Type: ${context.eventType}`); + console.log(` Bucket: ${file.bucket}`); + console.log(` File: ${file.name}`); + console.log(` Metageneration: ${file.metageneration}`); + console.log(` Created: ${file.timeCreated}`); + console.log(` Updated: ${file.updated}`); +}; +// [END functions_helloworld_storage_generic] From 60e739040539547a6cfa6728163175c785743608 Mon Sep 17 00:00:00 2001 From: Ace Nassri Date: Mon, 2 Jul 2018 17:54:36 -0700 Subject: [PATCH 08/15] Fix region tags --- functions/node8/index.js | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/functions/node8/index.js b/functions/node8/index.js index 30366017d7..618cc2d251 100644 --- a/functions/node8/index.js +++ b/functions/node8/index.js @@ -49,13 +49,6 @@ exports.retryPromise = (data, context) => { // [END functions_tips_retry_node8] // [START functions_helloworld_background_node8] - -// helloBackground -// helloPubSub -// helloGCS -// helloGCSGeneric - -// [START functions_helloworld_background] /** * Background Cloud Function. * @@ -64,9 +57,9 @@ exports.retryPromise = (data, context) => { exports.helloBackground = (data) => { return `Hello ${data.name || 'World'}!`; }; -// [END functions_helloworld_background] +// [END functions_helloworld_background_node8] -// [START functions_helloworld_pubsub] +// [START functions_helloworld_pubsub_node8] /** * Background Cloud Function to be triggered by Pub/Sub. * This function is exported by index.js, and executed when @@ -80,9 +73,9 @@ exports.helloPubSub = (event) => { console.log(`Hello, ${name}!`); }; -// [END functions_helloworld_pubsub] +// [END functions_helloworld_pubsub_node8] -// [START functions_helloworld_storage] +// [START functions_helloworld_storage_node8] /** * Background Cloud Function to be triggered by Cloud Storage. * @@ -99,9 +92,9 @@ exports.helloGCS = (file) => { console.log(`File ${file.name} metadata updated.`); } }; -// [END functions_helloworld_storage] +// [END functions_helloworld_storage_node8] -// [START functions_helloworld_storage_generic] +// [START functions_helloworld_storage_generic_node8] /** * Generic background Cloud Function to be triggered by Cloud Storage. * @@ -116,4 +109,4 @@ exports.helloGCSGeneric = (file, context) => { console.log(` Created: ${file.timeCreated}`); console.log(` Updated: ${file.updated}`); }; -// [END functions_helloworld_storage_generic] +// [END functions_helloworld_storage_generic_node8] From efa1957f669243c4f576eca4a1af3fff91ea87d0 Mon Sep 17 00:00:00 2001 From: michaelawyu Date: Tue, 17 Jul 2018 17:50:07 -0700 Subject: [PATCH 09/15] Updated sample functions_helloworld_pubsub_node8 --- functions/node8/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/functions/node8/index.js b/functions/node8/index.js index 618cc2d251..55f6310a13 100644 --- a/functions/node8/index.js +++ b/functions/node8/index.js @@ -65,11 +65,12 @@ exports.helloBackground = (data) => { * This function is exported by index.js, and executed when * the trigger topic receives a message. * - * @param {object} event The Cloud Functions event. + * @param {object} data The Cloud Functions event payload. + * @param {object} context The Cloud Functions metadata. */ -exports.helloPubSub = (event) => { - const pubsubMessage = event.data; - const name = pubsubMessage.data ? Buffer.from(pubsubMessage.data, 'base64').toString() : 'World'; +exports.helloPubSub = (data, context) => { + const pubsubMessage = data; + const name = pubsubMessage ? Buffer.from(pubsubMessage.data, 'base64').toString() : 'World'; console.log(`Hello, ${name}!`); }; From 1f069ec5b7c7a0a9ff7a20980e880ea799da5fce Mon Sep 17 00:00:00 2001 From: michaelawyu Date: Thu, 19 Jul 2018 13:37:36 -0700 Subject: [PATCH 10/15] Updated sample functions_helloworld_pubsub_node8 --- functions/node8/index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/functions/node8/index.js b/functions/node8/index.js index 55f6310a13..3a1c77cd47 100644 --- a/functions/node8/index.js +++ b/functions/node8/index.js @@ -68,9 +68,8 @@ exports.helloBackground = (data) => { * @param {object} data The Cloud Functions event payload. * @param {object} context The Cloud Functions metadata. */ -exports.helloPubSub = (data, context) => { - const pubsubMessage = data; - const name = pubsubMessage ? Buffer.from(pubsubMessage.data, 'base64').toString() : 'World'; +exports.helloPubSub = (pubsubMessage) => { + const name = pubsubMessage.data ? Buffer.from(pubsubMessage.data, 'base64').toString() : 'World'; console.log(`Hello, ${name}!`); }; From 788f15fa1a6eac0153f5b0491fd4d2ad7f9e0cd4 Mon Sep 17 00:00:00 2001 From: Ace Nassri Date: Thu, 19 Jul 2018 16:15:50 -0700 Subject: [PATCH 11/15] Fix docstrings --- functions/node8/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/functions/node8/index.js b/functions/node8/index.js index 3a1c77cd47..aa020fddff 100644 --- a/functions/node8/index.js +++ b/functions/node8/index.js @@ -52,7 +52,7 @@ exports.retryPromise = (data, context) => { /** * Background Cloud Function. * - * @param {object} event Data passed to the Cloud Function. + * @param {object} data Data passed to the Cloud Function. */ exports.helloBackground = (data) => { return `Hello ${data.name || 'World'}!`; @@ -98,7 +98,8 @@ exports.helloGCS = (file) => { /** * Generic background Cloud Function to be triggered by Cloud Storage. * - * @param {object} event The Cloud Functions event. + * @param {object} file The Cloud Functions event. + * @param {object} context The Cloud Functions event metadata. */ exports.helloGCSGeneric = (file, context) => { console.log(` Event ${context.eventId}`); From a81548c18f4b37e58bfa941589856d0fb96ed269 Mon Sep 17 00:00:00 2001 From: Ace Nassri Date: Thu, 19 Jul 2018 17:17:43 -0700 Subject: [PATCH 12/15] Fix comments + add license --- functions/node8/index.js | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/functions/node8/index.js b/functions/node8/index.js index aa020fddff..1aa19121ed 100644 --- a/functions/node8/index.js +++ b/functions/node8/index.js @@ -1,9 +1,16 @@ /** - * Background Cloud Function that only executes within - * a certain time period after the triggering event + * Copyright 2018, Google LLC. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * @param {object} event The Cloud Functions event. - * @param {function} callback The callback function. + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ // [START functions_tips_infinite_retries_node8] @@ -31,11 +38,11 @@ exports.avoidInfiniteRetries = (data, context) => { // [START functions_tips_retry_node8] /** - * Background Cloud Function that only executes within - * a certain time period after the triggering event + * Background Cloud Function that demonstrates + * how to toggle retries using a promise * - * @param {object} event The Cloud Functions event. - * @param {function} context Information about the event. + * @param {object} data The Cloud Functions event payload. + * @param {function} context The Cloud Functions metadata. */ exports.retryPromise = (data, context) => { const tryAgain = !!data.retry; @@ -79,7 +86,7 @@ exports.helloPubSub = (pubsubMessage) => { /** * Background Cloud Function to be triggered by Cloud Storage. * - * @param {object} file The Cloud Functions event. + * @param {object} file The Cloud Functions event payload. */ exports.helloGCS = (file) => { if (file.resourceState === 'not_exists') { @@ -98,7 +105,7 @@ exports.helloGCS = (file) => { /** * Generic background Cloud Function to be triggered by Cloud Storage. * - * @param {object} file The Cloud Functions event. + * @param {object} file The Cloud Functions event payload. * @param {object} context The Cloud Functions event metadata. */ exports.helloGCSGeneric = (file, context) => { From 23e6c14079fbb99f83f7bb6a41dad4a13db5f686 Mon Sep 17 00:00:00 2001 From: Ace Nassri Date: Fri, 20 Jul 2018 11:58:32 -0700 Subject: [PATCH 13/15] Use data parameter name --- functions/node8/index.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/functions/node8/index.js b/functions/node8/index.js index 1aa19121ed..dd1bfb2e38 100644 --- a/functions/node8/index.js +++ b/functions/node8/index.js @@ -75,8 +75,8 @@ exports.helloBackground = (data) => { * @param {object} data The Cloud Functions event payload. * @param {object} context The Cloud Functions metadata. */ -exports.helloPubSub = (pubsubMessage) => { - const name = pubsubMessage.data ? Buffer.from(pubsubMessage.data, 'base64').toString() : 'World'; +exports.helloPubSub = (data) => { + const name = data.data ? Buffer.from(data.data, 'base64').toString() : 'World'; console.log(`Hello, ${name}!`); }; @@ -86,17 +86,17 @@ exports.helloPubSub = (pubsubMessage) => { /** * Background Cloud Function to be triggered by Cloud Storage. * - * @param {object} file The Cloud Functions event payload. + * @param {object} data The Cloud Functions event payload. */ -exports.helloGCS = (file) => { - if (file.resourceState === 'not_exists') { - console.log(`File ${file.name} deleted.`); - } else if (file.metageneration === '1') { +exports.helloGCS = (data) => { + if (data.resourceState === 'not_exists') { + console.log(`File ${data.name} deleted.`); + } else if (data.metageneration === '1') { // metageneration attribute is updated on metadata changes. // on create value is 1 - console.log(`File ${file.name} uploaded.`); + console.log(`File ${data.name} uploaded.`); } else { - console.log(`File ${file.name} metadata updated.`); + console.log(`File ${data.name} metadata updated.`); } }; // [END functions_helloworld_storage_node8] @@ -105,16 +105,16 @@ exports.helloGCS = (file) => { /** * Generic background Cloud Function to be triggered by Cloud Storage. * - * @param {object} file The Cloud Functions event payload. + * @param {object} data The Cloud Functions event payload. * @param {object} context The Cloud Functions event metadata. */ -exports.helloGCSGeneric = (file, context) => { +exports.helloGCSGeneric = (data, context) => { console.log(` Event ${context.eventId}`); console.log(` Event Type: ${context.eventType}`); - console.log(` Bucket: ${file.bucket}`); - console.log(` File: ${file.name}`); - console.log(` Metageneration: ${file.metageneration}`); - console.log(` Created: ${file.timeCreated}`); - console.log(` Updated: ${file.updated}`); + console.log(` Bucket: ${data.bucket}`); + console.log(` File: ${data.name}`); + console.log(` Metageneration: ${data.metageneration}`); + console.log(` Created: ${data.timeCreated}`); + console.log(` Updated: ${data.updated}`); }; // [END functions_helloworld_storage_generic_node8] From aa73041670a9082ac4a4e72f163447f53800f424 Mon Sep 17 00:00:00 2001 From: Ace Nassri Date: Fri, 20 Jul 2018 12:01:49 -0700 Subject: [PATCH 14/15] Clarify README --- functions/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions/README.md b/functions/README.md index a0d5ec297b..8f954147fc 100644 --- a/functions/README.md +++ b/functions/README.md @@ -35,4 +35,4 @@ environment. * [Slack](slack/) ## Notes: -The samples in the `node8` directory are designed for use with Node.js `8.x.x`. Unless otherwise noted, all other samples are designed for Node.js `6.x.x`. \ No newline at end of file +The samples in the `node8` directory are designed for use with Node.js `8.x.x` only. Unless otherwise noted, all other samples are designed for _both_ Node.js `6.x.x` _and_ Node.js `8.x.x`. \ No newline at end of file From 1eeb4eae6b4bd843b0b78b2df25630ac2aa3aaae Mon Sep 17 00:00:00 2001 From: Ace Nassri Date: Fri, 20 Jul 2018 12:03:51 -0700 Subject: [PATCH 15/15] Clarify comments --- functions/node8/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/functions/node8/index.js b/functions/node8/index.js index dd1bfb2e38..a43e5e5c22 100644 --- a/functions/node8/index.js +++ b/functions/node8/index.js @@ -15,10 +15,10 @@ // [START functions_tips_infinite_retries_node8] /** - * Background Cloud Function that only executes within - * a certain time period after the triggering event + * Background Cloud Function that only executes within a certain time + * period after the triggering event to avoid infinite retry loops. * - * @param {object} event The Cloud Functions event. + * @param {object} event The Cloud Functions event payload. * @param {function} context Information about the event. */ exports.avoidInfiniteRetries = (data, context) => {