Skip to content

FoundryApp/examples

Repository files navigation

Foundry: Example projects

This repository is a set of example projects showing how Foundry can be used with Firebase. The overall theme is an app where you manage users and their workspaces.
Each directory is a separate Firebase Functions project showcasing different Foundry functionality.

Some projects integrate third party services like Slack or Sendgrid. You may want to join our Slack community where we provide API keys so you don't have to create an account with these services.

How to try Foundry with example projects:

  1. Install Foundry CLI by following instructions
  2. $ git clone https://github.com/FoundryApp/examples.git
  3. $ cd examples
  4. $ cd auth-functions/functions or any different example
  5. $ foundry go

Showcase of auth trigger functions: Create a default workspace for a new user and delete the user's data from Firestore when the user is deleted from Firebase Auth.

  • onCreate function newUserWorkspace creates a workspace in Firestore when a new user signs up

  • onDelete function userCleanup cleans a document of just deleted user in collection userInfos in Firestore + automatically updates all workspaces where the user was the owner

Showcase of the emulated Firebase Auth users: Fill the emulated Firebase Auth with custom users and with users from your production Firebase Auth.

  • https function getUserEmail returns an email of a user that is specified in the field collections in the function's request body

Showcase of the emulated Firestore database: Fill the emulated Firestore with custom documents and also with documents from your production Firestore database.

  • https function listCollectionsDocs lists documents from the collections specified in array collections in the function's request body

Showcase of Firestore trigger functions: Functionality around workspaces and Slack notifications. When you create a workspace with new members, add members to an existing workspace, or delete a workspace, a relevant Slack notification will be sent.

Functions in this project send Slack notifications and need an env variable named SLACK_WEBHOOK_URL to be set.
You can either get the webhook URL we created for this project from our Slack community or create your own webhook URL.
After getting an webhook URL run the command $ foundry env-set SLACK_WEBHOOK_URL=<the webhook URL>.

  • onCreate function notifyMembersInNewWorkspace sends a message to Slack mentioning all members from a newly created workspace

  • onUpdate function notifyMembersAddedToWorkspace sends a message to Slack mentioning all members that were added to an existing workspace

  • onDelete function notifyMembersInDeletedWorkspace sends a message to Slack mentioning all members that were in a deleted workspace

Showcase of HTTPS and HTTPS Callable functions: Custom API endpoints accessible by an HTTPS request or from within a Firebase app using the Firebase Client SDK.

Function askForWorkspaceInvite sends emails via Sendgrid and needs an env variable named SENDGRID_API_KEY to be set.
You can either get the API key we created for this project from our Slack community or create your own Sendgrid API key.
After getting an API key run the command $ foundry env-set SENDGRID_API_KEY=<the API key>.

  • https function askForWorkspaceInvite allows anyone to send a REST request asking the owner of a workspace for an invite. The request's body expects 2 fields:

    • workspaceId - an ID of a workspace
    • email - an email where the invite will be sent
  • httpsCallable function changeWorkspaceOwner allows your Firebase app users to change ownership of their workspace. The functions expects 2 parameters:

    • workspaceId - an ID of workspace where the ownership change should happen
    • newOwner - an ID of user that will become a new owner

About

A set of examples using Foundry with Firebase

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published