36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
|
|
"""Application configuration loaded from environment variables."""
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import os
|
||
|
|
|
||
|
|
|
||
|
|
class Config:
|
||
|
|
"""Base configuration. Reads from env vars; fails loud on missing secrets."""
|
||
|
|
|
||
|
|
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||
|
|
JWT_ALGORITHM = "HS256"
|
||
|
|
JWT_EXP_MINUTES = 60
|
||
|
|
MIN_PASSWORD_LENGTH = 8
|
||
|
|
|
||
|
|
def __init__(self) -> None:
|
||
|
|
db_path = os.environ.get("MIMIC_DB_PATH", "/data/mimic.sqlite")
|
||
|
|
self.SQLALCHEMY_DATABASE_URI = f"sqlite:///{db_path}"
|
||
|
|
|
||
|
|
jwt_secret = os.environ.get("MIMIC_JWT_SECRET")
|
||
|
|
if not jwt_secret:
|
||
|
|
raise RuntimeError(
|
||
|
|
"MIMIC_JWT_SECRET environment variable is required but not set."
|
||
|
|
)
|
||
|
|
self.JWT_SECRET = jwt_secret
|
||
|
|
|
||
|
|
|
||
|
|
class TestConfig(Config):
|
||
|
|
"""Config for pytest. Uses in-memory SQLite + fixed JWT secret."""
|
||
|
|
|
||
|
|
TESTING = True
|
||
|
|
|
||
|
|
def __init__(self) -> None:
|
||
|
|
# Bypass parent's env requirement; tests inject their own secret.
|
||
|
|
self.SQLALCHEMY_DATABASE_URI = "sqlite:///:memory:"
|
||
|
|
self.JWT_SECRET = "test-secret-do-not-use-in-prod"
|