Coder Social home page Coder Social logo

functions-as-a-service's Introduction

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

functions-as-a-service's People

Contributors

grant avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

functions-as-a-service's Issues

Auth protected paths examples.

Many thanks for this, I'm going to use it as boilerplate for new projects!

Would you also consider adding best practices for auth on functions within a specific path?

Missing output dir for tsconfig and missing env file.

I think you are missing an output dir in the ts config? I can't find the dir gcf and I don't see any tests

Also If I run deploy from master

โžœ  functions-as-a-service git:(829af1f) sh deploy.sh 
ERROR: (gcloud) Failed to load YAML from [.env.yaml]: Unable to read file [.env.yaml]: [Errno 2] No such file or directory: '.env.yaml'

Kind regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.