diff --git a/Node-1st-gen/ffmpeg-convert-audio/README.md b/Node-1st-gen/ffmpeg-convert-audio/README.md index 0b0bea295d..8063bcb791 100644 --- a/Node-1st-gen/ffmpeg-convert-audio/README.md +++ b/Node-1st-gen/ffmpeg-convert-audio/README.md @@ -21,7 +21,7 @@ To deploy and test the sample: - Create a Firebase project on the [Firebase Console](https://console.firebase.google.com) and visit the **Storage** tab. - Get the code, for instance using `git clone https://github.com/firebase/functions-samples` - Enter the correct directory `cd functions-samples/ffmpeg-convert-audio` -- Setup the CLI to use your Firebase project using `firebase use --add` and select your Firebase project +- Set up the CLI to use your Firebase project using `firebase use --add` and select your Firebase project - Deploy your project's code using `firebase deploy` - Go to the Firebase Console **Storage** tab and upload an audio. After a short time a converted audio with the same name but a `_output.flac` suffix will be created in the same folder (make sure you refresh the UI to see the new file). diff --git a/Node-1st-gen/paypal/README.md b/Node-1st-gen/paypal/README.md index 592bec60b8..2140184ff0 100644 --- a/Node-1st-gen/paypal/README.md +++ b/Node-1st-gen/paypal/README.md @@ -1,6 +1,6 @@ -# Accept PayPal payment in functions firebase +# Accept PayPal payment in Cloud Functions for Firebase -This sample demonstrates how to use the Paypal-rest-sdk with a Google Cloud Functions. +This sample demonstrates how to use the Paypal-rest-sdk with Google Cloud Functions. ## Functions Code @@ -55,10 +55,9 @@ To deploy and test on prod do: ## Contributing -We'd love that you contribute to the project. Before doing so please read our [Contributor guide](../CONTRIBUTING.md). +We'd love that you contribute to the project. Before doing so please read our [Contributor guide](../../CONTRIBUTING.md). ## License -© Google, 2017. Licensed under an [Apache-2](../LICENSE) license. - +© Google, 2017. Licensed under an [Apache-2](../../LICENSE) license. diff --git a/Node/test-functions-jest/README.md b/Node/test-functions-jest/README.md index 0c8ccf318d..64ec48f122 100644 --- a/Node/test-functions-jest/README.md +++ b/Node/test-functions-jest/README.md @@ -4,7 +4,7 @@ This quickstart demonstrates how to run unit tests on gen-2 functions. ## Setting up the sample -1. Clone or download this repo and open the `2nd-gen/test-functions-jest` +1. Clone or download this repo and open the `Node/test-functions-jest` directory. 1. Install Cloud Functions dependencies locally by running: `cd functions; npm install; cd -` diff --git a/Python/http-flask/README.md b/Python/http-flask/README.md index a4bdc8e823..f0dfcac69e 100644 --- a/Python/http-flask/README.md +++ b/Python/http-flask/README.md @@ -1 +1,32 @@ -# http-flask +# HTTP Flask Example + +This sample demonstrates how to expose a Flask app as a single Cloud Function. The Flask app provides a simple CRUD interface for "widgets" stored in the Realtime Database. + +## Functions Code + +See file [functions/main.py](functions/main.py) for the code. + +The sample creates a Flask app and defines two routes: + +- `GET /widgets` and `GET /widgets/`: These routes retrieve a list of all widgets or a single widget by its ID from the Realtime Database. +- `POST /widgets`: This route adds a new widget to the Realtime Database. + +The entire Flask app is then exposed as a single Cloud Function called `httpsflaskexample` using `@https_fn.on_request()`. + +## Trigger rules + +The `httpsflaskexample` function is triggered by an HTTP request. + +## Deploy and test + +To deploy and test the sample: + +1. Create a Firebase project on the [Firebase Console](https://console.firebase.google.com). +2. Get the code, for instance using `git clone https://github.com/firebase/functions-samples` +3. Enter the correct directory `cd functions-samples/Python/http-flask` +4. Set up the CLI to use your Firebase project using `firebase use --add` and select your Firebase project. +5. Deploy your project's code using `firebase deploy`. +6. Use a tool like `curl` to test the function: + - **Add a widget:** `curl -X POST -d "My new widget" https://us-central1-YOUR_PROJECT_ID.cloudfunctions.net/httpsflaskexample/widgets` + - **Get all widgets:** `curl https://us-central1-YOUR_PROJECT_ID.cloudfunctions.net/httpsflaskexample/widgets` + - **Get a specific widget:** `curl https://us-central1-YOUR_PROJECT_ID.cloudfunctions.net/httpsflaskexample/widgets/WIDGET_ID` diff --git a/Python/post-signup-event/README.md b/Python/post-signup-event/README.md index e9e2cfb4c2..eec53acc37 100644 --- a/Python/post-signup-event/README.md +++ b/Python/post-signup-event/README.md @@ -1 +1,33 @@ -# post-signup-event +# Post Sign-up Event with Google Calendar + +This sample demonstrates how to use an [Auth blocking function](https://firebase.google.com/docs/functions/auth-blocking-events) to save a user's Google OAuth2 access token to Firestore upon sign-up. It then uses a [task queue](https://firebase.google.com/docs/functions/task-functions) to schedule a Cloud Function that uses this token to create a Google Calendar event for the user. + +## Functions Code + +See file [functions/main.py](functions/main.py) for the code. + +The function `savegoogletoken` is an Auth blocking function that triggers before a user is created. If the user is signing up with Google, it saves their OAuth2 access token to a `user_info` collection in Firestore. It then creates a task to call the `scheduleonboarding` function. + +The `scheduleonboarding` function is a task queue function that retrieves the user's access token from Firestore, creates a new event on their primary Google Calendar, and then deletes the access token from Firestore. + +## Trigger rules + +- The `savegoogletoken` function is triggered by `beforeUserCreated` Auth blocking event. +- The `scheduleonboarding` function is triggered by a task queue. + +## Deploy and test + +To deploy and test the sample: + +1. Create a Firebase project on the [Firebase Console](https://console.firebase.google.com). +2. Enable the **Google Calendar API** for your project in the [Google Cloud Console](https://console.cloud.google.com/apis/library/calendar-json.googleapis.com). +3. Enable blocking functions for your project in the Firebase console: + - Go to the **Authentication** > **Settings** page. + - In the **Blocking functions** section, select **Before user creation (beforeCreate)** from the dropdown menu. + - Ensure that **Enable credential pass-through** is checked. +4. Get the code, for instance using `git clone https://github.com/firebase/functions-samples` +5. Enter the correct directory `cd functions-samples/Python/post-signup-event` +6. Set up the CLI to use your Firebase project using `firebase use --add` and select your Firebase project. +7. Deploy your project's code using `firebase deploy`. +8. Sign up for your app using a Google account. +9. After a minute, check your Google Calendar for a new "Onboarding with ExampleCo" event. diff --git a/README.md b/README.md index cfd5996697..61dc2ac07d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This repository contains a collection of samples showcasing some typical uses of [Cloud Functions for Firebase](https://firebase.google.com/features/functions). -Samples are available for the **Node** (2nd gen), **Python** (2nd gen), and Node (1st gen). +Samples are available for **Node** (1st and 2nd gen) and **Python** (2nd gen). > Note: Python support in Cloud Functions for Firebase is a public preview. This means that the functionality might change in backward-incompatible ways. A preview release is not subject to any SLA or deprecation policy and may receive limited or no support. @@ -55,7 +55,7 @@ This quickstart sample demonstrates using **Cloud Functions** triggered by **Rea - [Node 1st gen](/Node-1st-gen/quickstarts/big-ben/) -This quickstart demonstrates using **Cloud Functions** with an HTTPS trigger that's triggered through a Firebase Hosting URL. The function will display a repeated number of "BONG"s depending on the hour of the day. +This quickstart demonstrates using **Cloud Functions** with an HTTPS trigger that's triggered by a Firebase Hosting URL. The function will display a repeated number of "BONG"s depending on the hour of the day. ### Cloud Storage trigger quickstart: Thumbnail generator @@ -92,7 +92,7 @@ This quickstart sample demonstrates using **Cloud Functions** triggered by **Pub ### Test Lab trigger quickstart: Log when a matrix completes - [Node 2nd gen](/Node/quickstarts/testlab-matrix-completed/) -- [Python](/Python/quickstarts/testlab-matrix-completed/) +- [Python](/Python/quickstarts/testlab-matrix-completed) ### Firebase Alerts trigger quickstart: Send crash reports to Discord