Skip to content

Latest commit

 

History

History
77 lines (50 loc) · 2.21 KB

README.md

File metadata and controls

77 lines (50 loc) · 2.21 KB

Functions as a Service

The demo shows calling Google Maps Platform APIs from Google Cloud Functions.

Technologies

Develop

First install dependencies:

npm i

Then in one tab continually build the project with this command:

npm run build

In another tab, start the web server (and watch if the source code changes):

API_KEY=<KEY> npm run watch

This uses npm-watch with the functions-framework to auto re-build the server after changes.

Test locally

Go to http://localhost:8080 to run your Google Cloud Function locally.

Here are some example URL requests:

http://localhost:8080/directions?mode=driving&origin=37.7841393,-122.404467
http://localhost:8080/origins?origin=6
http://localhost:8080/places?origin=37.7841393,-122.114167

API Key

To create an API key, use the Cloud Console credentials page:

https://console.cloud.google.com/apis/credentials

More detailed instructions can be found in the "Get API Key" guide.

After creating an API key, enable these APIs:

Deploy

You must create a .env.yaml with your API Key:

API_KEY=AIsdfyCnTEiLTroDN14NTtpPm1n7jrBR844ID4A

You can deploy this project to Google Cloud Functions by running the following script:

gcloud config set project $MY_PROJECT
sh deploy.sh