terraform-provider-google/google/test-fixtures/cloudfunctions/pubsub_trigger.js

14 lines
420 B
JavaScript
Raw Normal View History

/**
* Background Cloud Function to be triggered by Pub/Sub.
*
* @param {object} event The Cloud Functions event.
* @param {function} callback The callback function.
*/
exports.helloPubSub = function (event, callback) {
const pubsubMessage = event.data;
const name = pubsubMessage.data ? Buffer.from(pubsubMessage.data, 'base64').toString() : 'World';
console.log(`Hello, ${name}!`);
callback();
};