27 lines
730 B
Python
27 lines
730 B
Python
from pydantic import AnyHttpUrl, validator
|
|
from pydantic_settings import BaseSettings
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
API_V1_STR: str = "/api/v1"
|
|
PROJECT_NAME: str = "Manga Inventory API"
|
|
VERSION: str = "0.1.0"
|
|
|
|
# CORS Configuration
|
|
BACKEND_CORS_ORIGINS: list[str | AnyHttpUrl] = ['*']
|
|
|
|
@validator("BACKEND_CORS_ORIGINS", pre=True)
|
|
def assemble_cors_origins(self, v: str | list[str]) -> list[str] | 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)
|
|
|
|
class Config:
|
|
case_sensitive = True
|
|
env_file = ".env"
|
|
|
|
|
|
settings = Settings()
|