This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "message": { | |
| "attributes": { "greeting": "Hello from the Cloud Pub/Sub Emulator!" }, | |
| "data": "SGVsbG8gQ2xvdWQgUHViL1N1YiEgSGVyZSBpcyBteSBtZXNzYWdlIQ==", | |
| "messageId": "136969346945" | |
| }, | |
| "subscription": "projects/myproject/subscriptions/mysubscription" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| curl -d "@mockPubsub.json" \ | |
| -X POST \ | |
| -H "Content-Type: application/json" \ | |
| http://localhost:8080 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "message": { | |
| "attributes": { | |
| "greeting": "Hello from the Cloud Pub/Sub Emulator!" | |
| }, | |
| "data": "SGVsbG8gQ2xvdWQgUHViL1N1YiEgSGVyZSBpcyBteSBtZXNzYWdlIQ==", | |
| "messageId": "136969346945" | |
| }, | |
| "subscription": "projects/myproject/subscriptions/mysubscription" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Background Cloud Function to be triggered by Pub/Sub. | |
| * This function is exported by index.js, and executed when | |
| * the trigger topic receives a message. | |
| * | |
| * @param {object} data The event payload. | |
| * @param {object} context The event metadata. | |
| */ | |
| exports.helloPubSub = (data, context) => { | |
| const pubSubMessage = context; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM gcr.io/gae-runtimes/php73:php73_20191020_7_3_10_RC00 | |
| WORKDIR /srv/ | |
| # NOTE: The entrypoint "/start", which starts up NGINX and PHP-FPM, | |
| # is configured by creating a `.googleconfig/app_start.json` file with the | |
| # contents: | |
| # | |
| # {"entrypointContents": "CUSTOM_ENTRYPOINT"} | |
| # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "require": { | |
| "google/cloud-functions-framework": "^0.1.0" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use Symfony\Component\HttpFoundation\Request; | |
| function helloHttp(Request $request) | |
| { | |
| return sprintf("Hello %s from PHP HTTP function!" . PHP_EOL, | |
| $request->query->get('name') ?: 'World' | |
| ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const mysql = require('promise-mysql'); | |
| // Create a pooled connection to MySQL | |
| let pool; | |
| const createPool = async () => { | |
| pool = await mysql.createPool({ | |
| user: process.env.DB_USER, // e.g. 'my-db-user' | |
| password: process.env.DB_PASS, // e.g. 'my-db-password' | |
| database: process.env.DB_NAME, // e.g. 'my-database' | |
| // If connecting via unix domain socket, specify the path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Create a Firebase client | |
| const admin = require('firebase-admin'); | |
| admin.initializeApp({ | |
| credential: admin.credential.applicationDefault() | |
| }); | |
| const db = admin.firestore(); | |
| async function uploadDoc(req, res) { | |
| // Create a reference to the shoes doc. | |
| let shoesDoc = db.collection('products').doc('shoes'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Imports the Google Cloud client library | |
| const {Storage} = require('@google-cloud/storage'); | |
| // Creates a client | |
| const storage = new Storage(); | |
| async function uploadFile(req, res) { | |
| // Uploads a local file to the bucket | |
| await storage.bucket(res.query.bucket).upload(req.query.filename, { | |
| // Support for HTTP requests made with `Accept-Encoding: gzip` |