
- Implemented project structure - Added SQLAlchemy models and database connection - Created Alembic migrations - Implemented CRUD API endpoints - Added health endpoint - Updated README.md generated with BackendIM... (backend.im)
24 lines
669 B
Python
24 lines
669 B
Python
from pydantic import BaseModel
|
|
from typing import Optional
|
|
from pathlib import Path
|
|
|
|
class Settings(BaseModel):
|
|
API_V1_STR: str = "/api/v1"
|
|
PROJECT_NAME: str = "Todo API"
|
|
PROJECT_DESCRIPTION: str = "A simple Todo API built with FastAPI and SQLite"
|
|
VERSION: str = "0.1.0"
|
|
|
|
# Database settings
|
|
DB_DIR: Path = Path("/app") / "storage" / "db"
|
|
SQLALCHEMY_DATABASE_URL: Optional[str] = None
|
|
|
|
class Config:
|
|
case_sensitive = True
|
|
|
|
settings = Settings()
|
|
|
|
# Ensure DB directory exists
|
|
settings.DB_DIR.mkdir(parents=True, exist_ok=True)
|
|
|
|
# Set the database URL
|
|
settings.SQLALCHEMY_DATABASE_URL = f"sqlite:///{settings.DB_DIR}/db.sqlite" |