
- Set up project structure with FastAPI - Configure SQLAlchemy with SQLite - Implement user and item models - Set up Alembic for database migrations - Create CRUD operations for models - Implement API endpoints for users and items - Add authentication functionality - Add health check endpoint - Configure Ruff for linting - Update README with comprehensive documentation
34 lines
898 B
Python
34 lines
898 B
Python
from pathlib import Path
|
|
from typing import List
|
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""Application settings."""
|
|
|
|
# API configuration
|
|
API_V1_STR: str = "/api/v1"
|
|
PROJECT_NAME: str = "Generic REST API Service"
|
|
PROJECT_DESCRIPTION: str = "A generic REST API service built with FastAPI"
|
|
PROJECT_VERSION: str = "0.1.0"
|
|
|
|
# CORS configuration
|
|
CORS_ORIGINS: List[str] = ["*"]
|
|
|
|
# Database configuration
|
|
DB_DIR: Path = Path("/app") / "storage" / "db"
|
|
SQLALCHEMY_DATABASE_URL: str = f"sqlite:///{DB_DIR}/db.sqlite"
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_file_encoding="utf-8",
|
|
case_sensitive=True
|
|
)
|
|
|
|
|
|
# Create settings instance
|
|
settings = Settings()
|
|
|
|
# Ensure database directory exists
|
|
settings.DB_DIR.mkdir(parents=True, exist_ok=True) |