45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
import os
|
|
from pathlib import Path
|
|
from typing import Any, List
|
|
|
|
from pydantic import BaseSettings, validator
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
PROJECT_NAME: str = "NoteTaker"
|
|
API_V1_STR: str = "/api/v1"
|
|
|
|
# CORS Configuration
|
|
BACKEND_CORS_ORIGINS: List[str] = ["*"]
|
|
|
|
@validator("BACKEND_CORS_ORIGINS", pre=True)
|
|
def assemble_cors_origins(cls, v: Any) -> List[str]:
|
|
if isinstance(v, str) and not v.startswith("["):
|
|
return [i.strip() for i in v.split(",")]
|
|
return v
|
|
|
|
# JWT Configuration
|
|
SECRET_KEY: str = os.getenv("SECRET_KEY", "supersecretkey")
|
|
ALGORITHM: str = "HS256"
|
|
ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 * 24 * 7 # 7 days
|
|
|
|
# Database Configuration
|
|
DB_DIR: Path = Path("/app") / "storage" / "db"
|
|
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
|
|
|
|
# File Storage Configuration
|
|
STORAGE_DIR: Path = Path("/app") / "storage"
|
|
ATTACHMENTS_DIR: Path = STORAGE_DIR / "attachments"
|
|
TEMP_DIR: Path = STORAGE_DIR / "temp"
|
|
|
|
# Create directories if they don't exist
|
|
DB_DIR.mkdir(parents=True, exist_ok=True)
|
|
ATTACHMENTS_DIR.mkdir(parents=True, exist_ok=True)
|
|
TEMP_DIR.mkdir(parents=True, exist_ok=True)
|
|
|
|
class Config:
|
|
case_sensitive = True
|
|
|
|
|
|
settings = Settings()
|