I'm trying to deploy a 2 Gen Google Cloud Function (trigger event type) as a module since I need to use import statement.
The problem is that GCP cannot find an entry point How should I modify following code?
index.js
const functions = require('@google-cloud/functions-framework');
// Register a CloudEvent callback with the Functions Framework that will
// be executed when the Pub/Sub trigger topic receives a message.
functions.cloudEvent('printPDFFromHTMLtest2', cloudEvent => {
// The Pub/Sub message is passed as the CloudEvent's data payload.
const base64name = cloudEvent.data.message.data;
const name = base64name
? Buffer.from(base64name, 'base64').toString()
: 'World';
console.log(`Hello, ${name}!`);
});
package.json
{
"dependencies": {
"@google-cloud/functions-framework": "^3.0.0"
}
}
I've managed to find a solution.
package.json
index.js