From 11a4b46777f41e4e3b7e195cbc31c6656db1752b Mon Sep 17 00:00:00 2001 From: Daniel Degraf Date: Fri, 13 Jan 2023 08:37:38 +0000 Subject: [PATCH] chore(functions/concepts): Migrate afterResponse sample to gen2 --- functions/concepts/afterResponse/index.js | 6 ++++-- functions/concepts/afterResponse/package.json | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/functions/concepts/afterResponse/index.js b/functions/concepts/afterResponse/index.js index 41935cbfeb..479511901a 100644 --- a/functions/concepts/afterResponse/index.js +++ b/functions/concepts/afterResponse/index.js @@ -15,6 +15,8 @@ 'use strict'; // [START functions_concepts_after_response] +const functions = require('@google-cloud/functions-framework'); + /** * HTTP Cloud Function that may not completely * execute due to early HTTP response @@ -22,10 +24,10 @@ * @param {Object} req Cloud Function request context. * @param {Object} res Cloud Function response context. */ -exports.afterResponse = (req, res) => { +functions.http('afterResponse', (req, res) => { res.end(); // This statement may not execute console.log('Function complete!'); -}; +}); // [END functions_concepts_after_response] diff --git a/functions/concepts/afterResponse/package.json b/functions/concepts/afterResponse/package.json index 589c079826..27f8469d71 100644 --- a/functions/concepts/afterResponse/package.json +++ b/functions/concepts/afterResponse/package.json @@ -10,5 +10,8 @@ }, "engines": { "node": ">=12.0.0" + }, + "dependencies": { + "@google-cloud/functions-framework": "^3.1.3" } }