A bare-bones starter kit for a typescript Google Cloud Function. My new-project-script repository is a convenient way to clone a repo, get rid of all the old history and have a shiny new repo to work in.
- Clone this repo into a folder on your local machine
- run
npm install - edit
package.jsona. insetProjectStagingreplacexxx-name-of-staging-projectwith the id of your GCF project. The id is similar but can be different from the name. By default GCP will attach a number to the name to create the id. b. optionally delete production scripts c. In deploy script changenameOfGcfFunctiontogcfHelloWorld - In
app,tschange name of function togcfHelloWorld - at terminal
npm run deploy:stagingsubsequent deploys can usenpm run deploy - In PostMan send a GET request of https://your-project-url.cloudfunctions.net/gcfHelloWorld . You can use the the GCP dashboard to go to the function, hit edit and get the full url from there.
- You should get back a response of
{“message”:”This your GCF Function responding.”}
If you switch between a staging and production environment you must run the script to set the default environment once. After that you can use the deploy script.