53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
from typing import List, Union, Optional
|
|
from pydantic import AnyHttpUrl, field_validator
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
class Settings(BaseSettings):
|
|
PROJECT_NAME: str = "Summit 14 Peaks"
|
|
API_V1_STR: str = "/api/v1"
|
|
ENVIRONMENT: str = "development"
|
|
|
|
# Database
|
|
POSTGRES_SERVER: str
|
|
POSTGRES_USER: str
|
|
POSTGRES_PASSWORD: str
|
|
POSTGRES_DB: str
|
|
POSTGRES_PORT: str
|
|
DATABASE_URL: str
|
|
|
|
# Redis
|
|
REDIS_URL: str
|
|
REDIS_HOST: str = "localhost"
|
|
REDIS_PORT: int = 6379
|
|
REDIS_DB: int = 0
|
|
|
|
# App
|
|
PORT: int = 8000
|
|
|
|
# Security
|
|
SECRET_KEY: str
|
|
ALGORITHM: str = "HS256"
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 1440
|
|
|
|
# CORS
|
|
BACKEND_CORS_ORIGINS: List[AnyHttpUrl] = []
|
|
|
|
@field_validator("BACKEND_CORS_ORIGINS", mode="before")
|
|
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)
|
|
|
|
# Static Files
|
|
UPLOAD_DIR: str
|
|
STATIC_URL_PREFIX: str
|
|
|
|
model_config = SettingsConfigDict(
|
|
case_sensitive=True,
|
|
env_file=".env",
|
|
extra="ignore"
|
|
)
|
|
|
|
settings = Settings() |