feat: enhance configuration for database and Redis integration in Docker setup
Test / test (push) Successful in 16s

This commit is contained in:
k1nq
2025-11-29 11:34:57 +05:00
parent f044bee416
commit c3bc6ef9f0
2 changed files with 46 additions and 7 deletions
+19 -3
View File
@@ -11,9 +11,15 @@ class Settings(BaseSettings):
project_name: str = "Test Task CRM"
version: str = "0.1.0"
api_v1_prefix: str = "/api/v1"
database_url: str = Field(
default="postgresql+asyncpg://postgres:postgres@0.0.0.0:5432/test_task_crm",
description="SQLAlchemy async connection string",
db_host: str = Field(default="localhost", description="Database hostname")
db_port: int = Field(default=5432, description="Database port")
db_name: str = Field(default="test_task_crm", description="Database name")
db_user: str = Field(default="postgres", description="Database user")
db_password: SecretStr = Field(default=SecretStr("postgres"), description="Database user password")
database_url_override: str | None = Field(
default=None,
alias="DATABASE_URL",
description="Optional full SQLAlchemy URL override",
)
sqlalchemy_echo: bool = False
jwt_secret_key: SecretStr = Field(default=SecretStr("change-me"))
@@ -29,5 +35,15 @@ class Settings(BaseSettings):
description="Maximum backoff (ms) for retrying cache writes/invalidation",
)
@property
def database_url(self) -> str:
if self.database_url_override:
return self.database_url_override
password = self.db_password.get_secret_value()
return (
f"postgresql+asyncpg://{self.db_user}:{password}@"
f"{self.db_host}:{self.db_port}/{self.db_name}"
)
settings = Settings()