first commit
This commit is contained in:
1
backend/app/core/__init__.py
Normal file
1
backend/app/core/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""Core configuration and shared helpers."""
|
||||
BIN
backend/app/core/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
backend/app/core/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
BIN
backend/app/core/__pycache__/config.cpython-312.pyc
Normal file
BIN
backend/app/core/__pycache__/config.cpython-312.pyc
Normal file
Binary file not shown.
47
backend/app/core/config.py
Normal file
47
backend/app/core/config.py
Normal file
@@ -0,0 +1,47 @@
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
app_name: str = "mktapi.ose.tw"
|
||||
app_version: str = "0.1.0"
|
||||
app_env: str = "development"
|
||||
log_level: str = "INFO"
|
||||
api_prefix: str = "/api"
|
||||
|
||||
db_host: str = "127.0.0.1"
|
||||
db_port: int = 5432
|
||||
db_database: str = "mkt.ose.tw"
|
||||
db_user: str = "mkt_ose"
|
||||
db_password: str = ""
|
||||
database_url: str = "postgresql+asyncpg://mkt_ose:@127.0.0.1:5432/mkt.ose.tw"
|
||||
|
||||
directus_base_url: str = "https://mktcms.ose.tw"
|
||||
directus_admin_token: str | None = None
|
||||
directus_timeout: float = 15.0
|
||||
cors_allowed_origins: str = (
|
||||
"http://127.0.0.1:3000,http://localhost:3000,"
|
||||
"http://127.0.0.1:5173,http://localhost:5173,"
|
||||
"https://127.0.0.1:3000,https://localhost:3000,"
|
||||
"https://127.0.0.1:5173,https://localhost:5173,"
|
||||
"https://mkt.ose.tw"
|
||||
)
|
||||
|
||||
@property
|
||||
def cors_allowed_origin_list(self) -> list[str]:
|
||||
"""Return normalized CORS origins from a simple comma-separated env value."""
|
||||
|
||||
return [
|
||||
origin.strip()
|
||||
for origin in self.cors_allowed_origins.split(",")
|
||||
if origin.strip()
|
||||
]
|
||||
|
||||
model_config = SettingsConfigDict(
|
||||
env_file=(".env.fastapi.development", ".env"),
|
||||
env_file_encoding="utf-8",
|
||||
case_sensitive=False,
|
||||
extra="ignore",
|
||||
)
|
||||
|
||||
|
||||
settings = Settings()
|
||||
Reference in New Issue
Block a user