A Pub/Sub triggered Node.js Cloud Run template.
Install dependencies:
npm installRun the function:
npm start
> hello-pubsub@0.0.1 start
> node index.js
Listening on port 8080Inside the scripts folder, run test_local.sh to test locally:
./test_local.sh
< HTTP/1.1 204 No Content
< X-Powered-By: Express
< Date: Tue, 21 Feb 2023 12:45:11 GMT
< Connection: keep-alive
< Keep-Alive: timeout=5You should see the following in the function logs:
Event ID: 6308619096677818
Event Type: google.cloud.pubsub.topic.v1.messagePublished
TextData: Hello World
Subscription: projects/MY-PROJECT/subscriptions/MY-SUBRun setup.sh to enable required services:
./setup.shRun deploy.sh to deploy to Google Cloud:
./deploy.shRun test_cloud.sh to test the service in Google Cloud:
./test_cloud.shWhen you're done, you can cleanup created resources:
./cleanup.sh