29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
import os
|
|
|
|
def require(key: str) -> str:
|
|
value = os.environ.get(key)
|
|
if not value:
|
|
raise RuntimeError(f"Required environment variable {key} is not set")
|
|
return value
|
|
|
|
def optional(key: str, default: str = "") -> str:
|
|
return os.environ.get(key, default)
|
|
|
|
# Required
|
|
JWT_SECRET_KEY = require("JWT_SECRET_KEY")
|
|
DATABASE_URL = require("DATABASE_URL")
|
|
RESEND_API_KEY = require("RESEND_API_KEY")
|
|
EMAIL_FROM = require("EMAIL_FROM")
|
|
STRIPE_SECRET_KEY = require("STRIPE_SECRET_KEY")
|
|
STRIPE_PUBLISHABLE_KEY = require("STRIPE_PUBLISHABLE_KEY")
|
|
STRIPE_WEBHOOK_SECRET = require("STRIPE_WEBHOOK_SECRET")
|
|
|
|
# Optional with sensible defaults for local dev
|
|
FRONTEND_URL = optional("FRONTEND_URL", "http://localhost:5173")
|
|
CORS_ORIGINS = optional("CORS_ORIGINS", "http://localhost:5173").split(",")
|
|
WIKIRANK_USER_AGENT = optional("WIKIRANK_USER_AGENT", "WikiTCG/1.0")
|
|
|
|
# Serves /docs, /redoc and /openapi.json, i.e. the whole API surface. Opt-in on an
|
|
# explicit "true" rather than off on a truthy value, so a typo or an unset var in
|
|
# a new environment fails closed.
|
|
ENABLE_DOCS = optional("ENABLE_DOCS").lower() == "true" |