Watch
1
0
Fork
You've already forked arc
0
forked from hesabix/arc
arc/hesabixAPI/build/lib/app/core/settings.py
2026-05-18 16:50:15 +00:00

51 lines
1.3 KiB
Python
Executable file

from functools import lru_cache
from pydantic import BaseModel, Field
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")
app_name: str = "Hesabix API"
app_version: str = "0.1.0"
api_v1_prefix: str = "/api/v1"
environment: str = "development"
debug: bool = True
# Database
db_user: str = "hesabix"
db_password: str = "change_me"
db_host: str = "localhost"
db_port: int = 5432
db_name: str = "hesabix"
sqlalchemy_echo: bool = False
# Logging — پیش‌فرض پروداکشن: حداقل خروجی
log_level: str = Field(
default="WARNING",
description="DEBUG | INFO | WARNING | ERROR | CRITICAL",
)
# Captcha / Security
captcha_length: int = 5
captcha_ttl_seconds: int = 180
captcha_secret: str = "change_me_captcha"
reset_password_ttl_seconds: int = 3600
# Phone normalization
# Used as default region when parsing phone numbers without a country code
default_phone_region: str = "IR"
# CORS
cors_allowed_origins: list[str] = ["*"]
@property
def postgresql_dsn(self) -> str:
return (
f"postgresql+psycopg2://{self.db_user}:{self.db_password}@{self.db_host}:{self.db_port}/{self.db_name}"
)
@lru_cache(maxsize=1)
def get_settings() -> Settings:
return Settings()