Configuring the application¶
Configuration is via environment.
Minimal .env
¶
Minimal .env
NAME=tmpl-starlite-saqlalchemy
DB_URL=postgresql+asyncpg://postgres:mysecretpassword@localhost:5432/postgres1
OPENAPI_CONTACT_EMAIL=peter.github@proton.me
OPENAPI_CONTACT_NAME="Peter Schutt"
OPENAPI_TITLE="Template starlite-saqlalchemy Application"
OPENAPI_VERSION=1.0.0
REDIS_URL=redis://localhost:6379/0
Local Development¶
Structured logs are nice when sending our logs through to some ingestion service, however, not so nice for local development.
set ENVIRONMENT=local
in your local .env
file for a nicer local development experience
(we implement
this structlog pattern
for you!).
Full .env
¶
Example .env
# App
BUILD_NUMBER=
CHECK_DB_READY=true
CHECK_REDIS_READY=true
DEBUG=true
ENVIRONMENT=local
NAME=my-starlite-app
# API
API_CACHE_EXPIRATION=60
API_DB_SESSION_DEPENDENCY_KEY=db_session
API_DEFAULT_PAGINATION_LIMIT=100
API_DTO_INFO_KEY=dto
API_HEALTH_PATH=/health
# Log
LOG_EXCLUDE_PATHS="\A(?!x)x"
LOG_HTTP_EVENT="HTTP"
LOG_INCLUDE_COMPRESSED_BODY=false
LOG_LEVEL=20
LOG_OBFUSCATE_COOKIES='["session"]'
LOG_OBFUSCATE_HEADERS='["Authorization","X-API-KEY"]'
LOG_REQUEST_FIELDS='["path","method","content_type","headers","cookies","query","path_params","body"]'
LOG_RESPONSE_FIELDS='["status_code","cookies","headers","body"]'
LOG_WORKER_EVENT="Worker"
LOG_SAQ_LEVEL=30
LOG_SQLALCHEMY_LEVEL=30
LOG_UVICORN_ACCESS_LEVEL=30
LOG_UVICORN_ERROR_LEVEL=30
# OpenAPI
OPENAPI_CONTACT_EMAIL=some_human@email.com
OPENAPI_CONTACT_NAME="Some Human"
OPENAPI_TITLE="My Starlite App"
OPENAPI_VERSION=1.0.0
# Database
DB_ECHO=false
DB_ECHO_POOL=false
DB_POOL_DISABLE=false
DB_POOL_MAX_OVERFLOW=10
DB_POOL_SIZE=5
DB_POOL_TIMEOUT=30
DB_URL=postgresql+asyncpg://postgres:mysecretpassword@pg.db.local:5432/db
# Redis
REDIS_URL=redis://cache.local:6379/0
# Sentry
SENTRY_DSN=
SENTRY_TRACES_SAMPLE_RATE=0.0001
# Server
SERVER_APP_LOC=app.main:app_factory
SERVER_APP_LOC_IS_FACTORY=true
SERVER_HOST=localhost
SERVER_KEEPALIVE=65
SERVER_PORT=8000
SERVER_RELOAD=false
SERVER_RELOAD_DIRS='[]'
# Worker
WORKER_JOB_TIMEOUT=10
WORKER_JOB_HEARTBEAT=0
WORKER_JOB_RETRIES=10
WORKER_JOB_TTL=600
WORKER_JOB_RETRY_DELAY=1.0
WORKER_JOB_RETRY_BACKOFF=60