JavaScript HTML CSS Objective-C Java Ruby
Latest commit 0199eed May 29, 2017 @nicolasgarnier nicolasgarnier committed on GitHub Removing step to configure Firebase on the client
Permalink
Failed to load latest commit information.
assistant-say-number Updating version of the firebase-functions module in package.json fil… Mar 8, 2017
authenticated-json-api Add authenticated-json-api sample. (#3) May 17, 2017
authorized-https-endpoint Some minor fixes in authorized-https-endpoint README May 13, 2017
bigquery-import Fixes 'bigquery.dataset' is not a function error Apr 5, 2017
child-count fixed typo Apr 18, 2017
convert-images Updating version of the firebase-functions module in package.json fil… Mar 8, 2017
coupon-on-purchase Removing awful typo addition. May 10, 2017
delete-unused-accounts-cron Change the uid property to localId in delete-unused-accounts-cron May 4, 2017
email-confirmation Update Firebase JS SDK version number. Apr 26, 2017
exif-images Update Firebase JS SDK version number. Apr 26, 2017
fcm-notifications Some minor fixes in authorized-https-endpoint README May 13, 2017
fulltext-search Fixes infinite loop :) Apr 4, 2017
generate-thumbnail Fix typo in Readme Apr 22, 2017
github-to-slack Prevent timing attacks on keys / signatures Apr 2, 2017
image-maker add server-side image generator sample May 17, 2017
instagram-auth Update Firebase JS SDK version number. Apr 26, 2017
isomorphic-react-app Add sample for server-side rendering of a React app (#1) May 17, 2017
lastmodified-tracking Switch $ to the correct format - {} Mar 21, 2017
limit-children Update index.js Apr 28, 2017
line-auth Fixes typos Apr 22, 2017
linkedin-auth Update Firebase JS SDK version number. Apr 26, 2017
message-translation Replace source with event parameter Apr 6, 2017
minimal-webhook Fixes #38 Mar 14, 2017
moderate-images Updating version of the firebase-functions module in package.json fil… Mar 8, 2017
quickstarts Removing step to configure Firebase on the client May 29, 2017
stripe fix typo on comments May 24, 2017
survey-app-update Updating version of the firebase-functions module in package.json fil… Mar 8, 2017
template-handlebars Add a handlebar template sample. May 13, 2017
text-moderation Update Firebase JS SDK version number. Apr 26, 2017
user-data-cleanup Fixed 'email sending quota' link. May 17, 2017
username-password-auth Some simplification Mar 29, 2017
.gitignore Misc doc fixes Mar 4, 2017
CONTRIBUTING.md Fixing repo name reference Mar 3, 2017
ISSUE_TEMPLATE.md Update ISSUE_TEMPLATE.md Mar 31, 2017
LICENSE Adding initial README, license files and CONTRIBUTING rules. Jan 15, 2016
README.md Add sample for server-side rendering of a React app (#1) May 17, 2017

README.md

Cloud Functions for Firebase Sample Library

This repository contains a collection of samples showcasing some typical uses of Cloud Functions for Firebase.

What's Cloud Functions for Firebase?

Cloud Functions is a hosted, private, and scalable Node.js environment where you can run JavaScript code. Cloud Functions for Firebase integrates the Firebase platform by letting you write code that responds to events and invokes functionality exposed by other Firebase features.

Prerequisites

To learn how to get started with Cloud Functions for Firebase by having a look at our Getting Started Guide, trying the quickstart samples and looking at the documentation.

Use Cases and Samples

This repository contains the following samples:

Realtime database trigger quickstart: Uppercaser

This quickstart sample demonstrates using Cloud Functions triggered by Firebase Realtime Database events. The function uppercase messages written to the datastore.

HTTPS trigger quickstart: Time Server

This quickstart sample demonstrates using Cloud Functions triggered by HTTPS requests. The function returns the current server time and allows for date time formatting.

Hosting triggered HTTPS function quickstart: 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" depending on the hour of the day.

Cloud Storage trigger quickstart: Thumbnail generator

This quickstart sample demonstrates using Cloud Functions triggered by Firebase Storage events. The function generates a thumbnail of uploaded images.

Auth trigger quickstart: Welcome Email

This quickstart sample demonstrates using Cloud Functions triggered by Firebase Auth events. The functions sends a Welcome email when user accounts are created (or when users signs-in using an Identity Provider for the first time) and sends a Goodbye email when user accounts are deleted.

PubSub trigger quickstart: Hello World

This quickstart sample demonstrates using Cloud Functions triggered by PubSub events. The functions log the PubSub payload in a Hello world message.

Authenticated JSON API

This sample shows how to authenticate access to a JSON API to only allow access to data for a specific Firebase user.

Authorized HTTP endpoint

This samples shows how to restrict an HTTPS Function to only the Firebase users of your app. Only users who pass a valid Firebase ID token as a Bearer token in the Authorization header of the HTTP request or in a __session cookie are authorized to use the function. Checking the ID token is done with an ExpressJs middleware that also passes the decoded ID token in the Express request object. Uses an HTTP trigger.

Server-side generated pages w/ Handlebars templating and user sessions

This samples shows how to serve server-side generated HTML pages using the HandlebarsJs templating system and serve User specific content by always passing the Firebase ID token in a __session cookie.

Google Assistant says ordinal of given number

This sample shows how to create an action for the Google Home/Assistant using the Actions SDK hosted on Cloud Functions. The sample action asks users to say a number and reads out the ordinal of that number. Uses an HTTP trigger.

Send FCM notifications

This sample demonstrates how to send a Firebase Cloud Messaging (FCM) notification from a Realtime Database triggered Function when users get new followers. The sample also features a Web UI to experience the FCM notification. Uses a Realtime Database trigger.

Authorize with LinkedIn

Demonstrates how to authorize with a 3rd party sign-in mechanism (LinkedIn in this case), create a Firebase custom auth token, update the user's profile and authorize Firebase. Uses an HTTP trigger.

Image Maker

This sample demonstrates how to create various customized images through Cloud Functions and Hosting and serve it to the client.

Authorize with Instagram

Demonstrates how to authorize with a 3rd party sign-in mechanism (Instagram in this case), create a Firebase custom auth token, update the user's profile and authorize Firebase. Uses an HTTP trigger.

Isomorphic React App

This sample demonstrates how to create an isomorphic React application with server-side data fetching. This sample uses Cloud Functions, Hosting, and the Realtime Database.

Authorize with LINE

Demonstrates how to authorize with a 3rd party sign-in mechanism (LINE in this case), create a Firebase custom auth token, update the user's profile and authorize Firebase. Uses an HTTP trigger.

Convert images after upload

Demonstrates how to automatically convert images that are uploaded to Firebase Storage to JPEG using ImageMagick. Uses a Firebase Storage trigger.

Generate image thumbnails after upload

Demonstrates how to automatically generate a thumbnail for images that are uploaded to Firebase Storage. Uses a Firebase Storage trigger.

Post GitHub commits to Slack channel

Demonstrates how to automatically post GitHub commits to a Slack channel using an HTTPS triggered Function.

Create and charge Stripe customers

Demonstrates hows to integrate Firebase Auth and the Realtime database with Stripe via the Stripe Node.js library.

Moderate offensive images

Demonstrates how to automatically moderate offensive images that are uploaded to Firebase Storage by using the Google Cloud Vision API to detect offensive images and ImageMagick to blur these images. Uses a Firebase Storage trigger.

Extract image metadata

Demonstrates how to automatically extract image's metadata using ImageMagick for images that are uploaded to Firebase Storage. Uses a Firebase Storage trigger.

Text moderation

How to moderate user input text for bad words. For example this can be used to moderate usernames, chat or forum messages. Uses an Realtime Database trigger.

Email confirmation

Sends email confirmation after users subscribed to a mailing list. Uses an Realtime Database trigger.

LastModified Firebase Database tracking

Tracking when the Firebase Database (or a subset) was last modified. Uses an Realtime Database trigger.

Webhook upon Firebase Database writes

Writing to the Firebase Database triggers a request to a callback URL (a Webhook). The content of the modified Data is sent to the Webhook. Uses an Realtime Database trigger.

Firebase Database child nodes count

Keeps track of the number of child nodes of a Firebase Database element allowing clients to filter or order results using the child count. This can be useful to keep tack of the number of "likes" or "followers" of a somethings shares through social media. Uses an Realtime Database trigger.

Automatic message translation

Integrates the Google Translate API to perform automatic text translation across any number of languages. Language codes can be stored in Firebase for on the fly changes. Uses an Realtime Database trigger.

Limit number of child nodes

Make sure to keep the number of child nodes below a certain threshold. For instance this can be useful to limit the number of lines of logs or chat history below a given number. Uses an Realtime Database trigger.

Import data into Big Query

Copies Firebase Database elements into BigQuery automatically. This can be useful for instance for further logs analysis. Uses an Realtime Database trigger.

Full-text search via Algolia

Enable full-text search on firebase database elements by using an Algolia hosted search service. Uses an Realtime Database trigger.

User data cleanup

Deletes all associated user data that's on the Realtime database when a user deletes his Firebase account. Uses an Auth trigger.

Send a survey when users update your app

This sample shows how to send a survey to your users who have updated your app. App Update is detected using a Firebase Analytics event. Uses an Analytics trigger.

Send a coupon to user who have completed a purchase

This sample shows how to send a coupon to your users who have just purchased something. 10% off on your next purchase! Uses an Analytics trigger.

Delete inactive users accounts via cron

Periodically deletes the accounts of users who have not signed in the last month. Uses an HTTPS trigger.

Username/password sign in with Firebase

Demonstrates how to authorize with a username/password sign-in mechanism, create a Firebase custom auth token, update the user's profile and authorize Firebase. Uses an HTTP trigger.

Contributing

We'd love that you contribute to the project. Before doing so please read our Contributor guide.

License

© Google, 2015. Licensed under an Apache-2 license. Uses a Realtime Database trigger.