This file contains 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
/** | |
* Gets driving directions from Mountain View to San Francisco. | |
* Derived from https://github.com/googleworkspace/apps-script-samples/blob/main/sheets/maps/maps.gs | |
* @customfunction | |
*/ | |
function getDrivingDirections() { | |
// Set starting and ending addresses | |
var start = '1600 Amphitheatre Pkwy, Mountain View, CA 94043'; | |
var end = '345 Spear St, San Francisco, CA 94105'; | |
var directions = Maps.newDirectionFinder().setOrigin(start).setDestination(end).getDirections(); |
This file contains 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
{ | |
"main": "index.js", | |
"dependencies": { | |
"@google-cloud/functions-framework": "^2.1.0" | |
}, | |
"watch": { | |
"start": "*.js" | |
}, | |
"devDependencies": { | |
"npm-watch": "^0.11.0" |
This file contains 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
{ | |
"main": "index.js", | |
"dependencies": { | |
"@google-cloud/functions-framework": "^2.1.0" | |
}, | |
"scripts": { | |
"start": "npx @google-cloud/functions-framework --target=helloWorld" | |
} | |
} |
This file contains 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 FunctionsFramework = require('@google-cloud/functions-framework'); | |
FunctionsFramework.http('helloWorld', (req, res) => { | |
res.send('Hot-reload me?'); | |
}); |
This file contains 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
> npm start | |
> [email protected] start /Users/timmerman/Documents/github/googlecloudplatform/functions-framework-nodejs/docs/esm | |
> functions-framework --target=esm | |
Serving function... | |
Function: esm | |
Signature type: http | |
URL: http://localhost:8080/ |
This file contains 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
export function esm(req, res) { | |
res.send(`Hello, ${MY_CONST}!`); | |
}; |
This file contains 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
import {MY_CONST} from './consts.js'; |
This file contains 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
export const MY_CONST = 'ESM'; |
This file contains 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
{ | |
"name": "nodejs-ff-esm", | |
"type": "module", | |
"engines": { | |
"node": ">=12.0.0" | |
}, | |
"scripts": { | |
"start": "functions-framework --target=esm" | |
}, | |
"dependencies": { |
This file contains 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
# Add secret for project | |
PROJECT=$(gcloud config get-value project) | |
gh secret set GCP_PROJECT_ID -b $PROJECT | |
# Create service account | |
SERVICE_ACCOUNT=my-wf-service-account | |
gcloud iam service-accounts create $SERVICE_ACCOUNT | |
gcloud projects add-iam-policy-binding $PROJECT \ | |
--member "serviceAccount:$SERVICE_ACCOUNT@$PROJECT.iam.gserviceaccount.com" \ | |
--role "roles/workflows.editor" |
NewerOlder