contacts
Contact Karma's Contact API
Authenticating
Emulators & Local Dev
cd ./emulators
docker-compose build
docker-compose up -d
Environment Variables
The following environment variables are required.
For local development a .env file can be created from .env.sample.
ALLOWED_ORIGIN | "*" | Needs to be restricted |
ENV | "local" | local, dev, prod |
FIREBASE_URL | "contactkarma-dev.firebaseapp.com" | |
FRONTEND_URL | "https://contactkarma.dev" | |
GOOGLE_CLOUD_PROJECT | "contactkarma-dev" | |
GOOGLE_APPLICATION_CREDENTIALS | "/path/to/key/file/key.json" | Required for local dev to auth with Firebase |
PORT | "8080" | Cloud Run default |
Used for local dev with emulators
Authentication
- Firebase Auth is validated by API Gateway
- The origional Firebase Auth JWT is copied from Authorization to X-Apigateway-Api-Userinfo
securityDefinitions:
Bearer:
type: apiKey
in: header
name: X-Apigateway-Api-Userinfo
description: JWT Token
security:
- Bearer: []
Running Tests locally
Run test using the command (replace $PATH_TO_ENV_FILE with absoulte file path to env file):
TEST_ENV_PATH=$PATH_TO_ENV_FILE go test -cover ./...
Optionally set TEST_ENV_PATH in vscode extension settings and use test runner tool
"go.testEnvVars": {
"TEST_ENV_PATH": "~INSERT_ABSOLUTE_PATH_TO_ENV_FILE~"
}