Skip to content

daostack/common-backend

Repository files navigation

codecov

Common Backend

The backend for the Common.io app. It is a Firebase project with a Firestore database and a set of cloud functions.

Installation

  1. Extract relevant env files to ./env. Ask teammate for them.
    1. You might need to create empty folder in functions/src/shared/configs/env
  2. Install firebase tools globally: npm install -g firebase-tools
    1. login: firebase login
  3. Install dependencies: cd functions; npm ci; npm run prepare:hooks
  4. Run tsc
  5. Sync env files: npm run use:dev (see them below)
  6. open 2 terminals:
    1. npx tsc -w
    2. NODE_ENV=local-dev FIRESTORE_EMULATOR_HOST=localhost:8080 firebase emulators:start

public Dev env

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)

  1. firebase use dev
  2. npm run use:dev
  3. npm run deploy:dev

E2E tests

  1. Run the firebase emulators with npm run dev
  2. Compile the firebase functions in background with npm run build:watch
  3. 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.

FAQ

- How do I run a migration in the local emulator?

  1. Run the emulator with npm run dev:data (or npm run dev if you want to start with a clean DB)
  2. 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)

- How do I import data from an environment to the local emulator?

You may need to install the gcloud CLI.

  1. Temporarily change the default project in the .firebaserc file to the environment you want to import from.
  2. Run npm run import:firestore
  3. Run npm run import:auth
  4. Restore the default project in the .firebaserc file.
  5. Run npm run dev:data

About

Common's backend

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 14

Languages