44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
import os
|
|
from typing import List, Union
|
|
|
|
from pydantic import AnyHttpUrl, field_validator
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
API_V1_STR: str = "/api/v1"
|
|
SECRET_KEY: str = os.environ.get("SECRET_KEY", "development_secret_key")
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = int(os.environ.get("ACCESS_TOKEN_EXPIRE_MINUTES", "60")) # 1 hour
|
|
|
|
# Project info
|
|
PROJECT_NAME: str = "Healthcare Management System"
|
|
PROJECT_DESCRIPTION: str = "Backend API for Healthcare Management System"
|
|
VERSION: str = "0.1.0"
|
|
|
|
# CORS
|
|
BACKEND_CORS_ORIGINS: List[AnyHttpUrl] = []
|
|
|
|
@field_validator("BACKEND_CORS_ORIGINS", mode="before")
|
|
def assemble_cors_origins(cls, v: Union[str, List[str]]) -> Union[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)
|
|
|
|
# JWT
|
|
JWT_SECRET: str = os.environ.get("JWT_SECRET", SECRET_KEY)
|
|
JWT_ALGORITHM: str = "HS256"
|
|
|
|
# Database
|
|
DB_DIR: str = "/app/storage/db"
|
|
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
|
|
|
|
# SQLAlchemy config
|
|
SQLALCHEMY_TRACK_MODIFICATIONS: bool = False
|
|
SQLALCHEMY_ECHO: bool = False
|
|
|
|
model_config = SettingsConfigDict(case_sensitive=True)
|
|
|
|
|
|
settings = Settings() |