Firebase Functions that power Quatro.
📄 General technical documentation: https://github.com/usequatro/quatro-docs
All code is inside src
. See index.ts
for currently available endpoints and scheduled functions.
In 2022, Quatro's team decided to stop the project. Check out this blog post to learn more: What a B2B PM Learned About Building Consumer Products.
If you have a technical question or want to contribute, feel free to open an issue.
- Run local emulator:
npm run serve
- Firebase Functions are regular functions exported from
src/index.ts
There are 2 Firebase environments.
dev
, for development environments, with Firebase projectquatro-dev-88030
prod
, with Firebase projecttasket-project
You can check which one you have active locally by running firebase use
. To switch, use firebase use [dev|prod]
To check what the environment variables are in the cloud, use firebase functions:config:get
Environment variables aren't tracked in source control or locally. Simply update them in the different environments using firebase functions:config:set [key]=[value]
. Note the key can be nested, like activeCampaign.url
.
Documentation: Firebase Functions Environment Configuration
Initial setup:
- Download the environment variables for the Firebase Emulator with
firebase functions:config:get > .runtimeconfig.json
. Then runexport GOOGLE_APPLICATION_CREDENTIALS="$(pwd)/.runtimeconfig.json"
. This is good for emulator, but open a new terminal for deploying so it doesn't use them.
To work with HTTP functions with functions pointing to a deployed Firebase project,
- On a different terminal, on this repository, run
npm run build-watch
- Run
firebase emulators:start
To work with rest of the application
- On the
quatro-web-client
repository, runfirebase emulators:start
- On a different terminal, on this repository, run
npm run build-watch
Note that the emulator is fairly recent and there are some issues with it. Notably, the callable function storeAuthCode
doesn't work as expected there, so you might need to copy tokens from the real dev environment for the Google Calendar sync to work.
Check before which environment you're deploying with firebase use
. Then:
- All functions:
npm run deploy
orfirebase deploy --only functions
- Only one function:
firebase deploy --only functions:[fname]
- Multiple functions:
firebase deploy --only functions:[fname1],functions:[fname2]
We use the Firebase Functions Logger (documentation, API reference).