Backend API for Gated.
The following services are required at runtime:
- PostgreSQL Database
- Google pub/sub service
- Redis
- Google API
- SendGrid (not required for dev)
- node version >= 16.0
- docker version >= 20.10
- GCP Project
- The project may need to be created for you. See this document for additional GCP project configuration requirements.
npm install
-
cp ./.env.example ./.env
-
edit the
.env
file and populate values for:{name}
: use the personal name value used to name the GCP project created for you. i.e. copy{name}
fromgated-dev-{name}
{populate}
: various values that include keys from the associated GCP project- refer to the GCP Product Configuration document for specific values to set in the
.env
file.
-
Add
AUTH_ADMIN_DOMAIN
to.env
and set to the email domain of a test user. For exampleAUTH_ADMIN_DOMAIN=gated.com
- when signing up with the test account, the account should be assigned as an admin. This is particularly useful for using the admin client.
-
Set value for
AUTH_FIREBASE_API_KEY
. This should come from the 'Browser Key' generated by Firebase under API Keys. -
Set
GCLOUD_PROJECT
to your GCP project name
Services for local development are defined in a docker compose configuration docker/docker-compose.yaml
.
When starting for the first time, run the init task.
npm run dev:init
npm run dev:up
By default, the postgresql service defined in the docker compose configuration mounts docker/docker-volumes/data/pg
to the container so that data is persisted.
A containerized version of a Google pub/sub service is defined in the docker compose configuration. This version is considered an emulator and does not support the same level of functionality as the actual cloud service. Using the emulator is faster and more convenient for development purposes, but you'll need to use the actual service if you want to work with full email functionality.
You can control which version of this service is used via the env var:
PUBSUB_EMULATOR_HOST=localhost:8538
npm run db:migrate
to create the schemanpm run db:seed
to initialize some seed data
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
The database needs to be seeded before running tests. This should generally only be required once.
$ npm run db:seed
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov