All Projects → googlesamples → functions-as-a-service

googlesamples / functions-as-a-service

Licence: Apache-2.0 License
A demo showing Google Cloud Functions + Google Maps Platform

Programming Languages

typescript
32286 projects
shell
77523 projects

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].