The backend for the Common.io app. It is a Firebase project with a Firestore database and a set of cloud functions.
- Extract relevant env files to ./env. Ask teammate for them.
- You might need to create empty folder in functions/src/shared/configs/env
 
- You might need to create empty folder in 
- Install firebase tools globally: npm install -g firebase-tools- login: firebase login
 
- login: 
- Install dependencies: cd functions; npm ci; npm run prepare:hooks
- Run tsc
- Sync env files: npm run use:dev(see them below)
- open 2 terminals:
- npx tsc -w
- NODE_ENV=local-dev FIRESTORE_EMULATOR_HOST=localhost:8080 firebase emulators:start
 
If you want to have a safe dev space for tests, use the dedicated Firebase project for it (make sure you have the relevant env files from Env set up in Notion)
- firebase use dev
- npm run use:dev
- npm run deploy:dev
- Run the firebase emulators with npm run dev
- Compile the firebase functions in background with npm run build:watch
- Run the tests in watch mode with npm run test-e2e
Optional: Set TRIGGERS_TIMEOUT_MS env variable to a lower value to execute tests faster, at the expense of increasing the likelyhood of missing a trigger while
asserting a condition.
- Run the emulator with npm run dev:data(ornpm run devif you want to start with a clean DB)
- Run NODE_ENV=local-dev FIRESTORE_EMULATOR_HOST=127.0.0.1:8080 npx ts-node src/migrations/{migrationName}.ts(replace {migrationName} with the name of the migration you want to run)
You may need to install the gcloud CLI.
- Temporarily change the default project in the .firebaserc file to the environment you want to import from.
- Run npm run import:firestore
- Run npm run import:auth
- Restore the default project in the .firebaserc file.
- Run npm run dev:data