2025-06-02 19:18:33 +00:00

33 lines
762 B
Python

from pathlib import Path
from pydantic_settings import BaseSettings
from typing import List
class Settings(BaseSettings):
"""Application settings."""
# Base
APP_NAME: str = "REST API Service"
API_V1_STR: str = "/api/v1"
# CORS
CORS_ORIGINS: List[str] = ["*"]
# Database
DB_DIR: Path = Path("/app") / "storage" / "db"
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
class Config:
env_file = ".env"
case_sensitive = True
# Create DB directory if it doesn't exist
def create_db_dir():
"""Create database directory if it doesn't exist."""
settings = Settings()
settings.DB_DIR.mkdir(parents=True, exist_ok=True)
# Get settings instance
settings = Settings()