From 164ae07e951ad78967d207b79dbdf2b32db725e6 Mon Sep 17 00:00:00 2001 From: labtopia Date: Thu, 14 Jun 2018 15:14:50 -0700 Subject: [PATCH 1/2] Add code comments to file --- functions/ocr/app/index.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/functions/ocr/app/index.js b/functions/ocr/app/index.js index 0c7e6ed766..3f06a4201e 100644 --- a/functions/ocr/app/index.js +++ b/functions/ocr/app/index.js @@ -104,7 +104,13 @@ function renameImageForSave (filename, lang) { // [START functions_ocr_process] /** - * Cloud Function triggered by Cloud Storage when a file is uploaded. + * This function is exported by index.js, and is executed when + * a file is uploaded to the Cloud Storage bucket you created + * for uploading images. + * + * @param {object} event The Cloud Functions event. + * @param {object} event.data A Google Cloud Storage File object. + */ * * @param {object} event The Cloud Functions event. * @param {object} event.data A Google Cloud Storage File object. @@ -136,8 +142,10 @@ exports.processImage = (event) => { // [START functions_ocr_translate] /** - * Translates text using the Google Translate API. Triggered from a message on - * a Pub/Sub topic. + * This function is exported by index.js, and is executed when + * a message is published to the Cloud Pub/Sub topic specified + * by the TRANSLATE_TOPIC value in the config.json file. The + * function translates text using the Google Translate API. * * @param {object} event The Cloud Functions event. * @param {object} event.data The Cloud Pub/Sub Message object. @@ -186,8 +194,10 @@ exports.translateText = (event) => { // [START functions_ocr_save] /** - * Saves the data packet to a file in GCS. Triggered from a message on a Pub/Sub - * topic. + * This function is exported by index.js, and is executed when + * a message is published to the Cloud Pub/Sub topic specified + * by the RESULT_TOPIC value in the config.json file. The + * function saves the data packet to a file in GCS. * * @param {object} event The Cloud Functions event. * @param {object} event.data The Cloud Pub/Sub Message object. From 2fc477e1fc4cffae703f8ebf2c94a223641ed8f2 Mon Sep 17 00:00:00 2001 From: Ace Nassri Date: Fri, 15 Jun 2018 15:32:40 -0700 Subject: [PATCH 2/2] Fix syntax error --- functions/ocr/app/index.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/functions/ocr/app/index.js b/functions/ocr/app/index.js index 3f06a4201e..e091ee6067 100644 --- a/functions/ocr/app/index.js +++ b/functions/ocr/app/index.js @@ -111,10 +111,6 @@ function renameImageForSave (filename, lang) { * @param {object} event The Cloud Functions event. * @param {object} event.data A Google Cloud Storage File object. */ - * - * @param {object} event The Cloud Functions event. - * @param {object} event.data A Google Cloud Storage File object. - */ exports.processImage = (event) => { let file = event.data;