Spaces:
Running
Running
File size: 1,096 Bytes
29cbab9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | from typing import Union
from pydantic import SecretStr, field_validator
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
# Supabase / PostgreSQL
DATABASE_URL: str
# JWT
SECRET_KEY: SecretStr
ALGORITHM: str = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 # 24 hours
# App
APP_NAME: str = "DocBoard"
DEBUG: bool = False
ALLOWED_ORIGINS: Union[list[str], str] = ["http://localhost:5173", "http://127.0.0.1:5173"]
# Supabase
SUPABASE_JWT_SECRET: SecretStr
@field_validator("ALLOWED_ORIGINS", mode="before")
@classmethod
def assemble_cors_origins(cls, v: Union[str, list[str]]) -> list[str]:
if isinstance(v, str) and not v.startswith("["):
return [i.strip() for i in v.split(",")]
elif isinstance(v, (list, str)):
return v
raise ValueError(v)
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
extra="ignore"
)
settings = Settings()
|