Automated Action b00b44023a Add FastAPI REST API with SQLite database
- Set up project structure
- Add database models and SQLAlchemy setup
- Configure Alembic for migrations
- Create API endpoints for items
- Add health check endpoint
- Update documentation

generated with BackendIM... (backend.im)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-05-15 22:33:58 +00:00

35 lines
1002 B
Python

from fastapi import FastAPI, APIRouter
from fastapi.middleware.cors import CORSMiddleware
from app.core.config import settings
from app.api.v1.endpoints import health, items
# Create FastAPI app
app = FastAPI(
title=settings.PROJECT_NAME,
description=settings.DESCRIPTION,
version=settings.VERSION,
openapi_url=f"{settings.API_V1_STR}/openapi.json",
docs_url="/docs",
redoc_url="/redoc",
)
# Set up CORS
if settings.BACKEND_CORS_ORIGINS:
app.add_middleware(
CORSMiddleware,
allow_origins=[str(origin) for origin in settings.BACKEND_CORS_ORIGINS],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Create API router
api_router = APIRouter()
# Include routers from endpoints
api_router.include_router(health.router, prefix="/health", tags=["health"])
api_router.include_router(items.router, prefix="/items", tags=["items"])
# Add API router to app
app.include_router(api_router, prefix=settings.API_V1_STR)