Files
family-hub/backend/app/main.py

58 lines
1.7 KiB
Python

"""Main FastAPI application."""
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
from pathlib import Path
from app.core.config import settings
from app.api.v1 import auth, users, chores, uploads, public, chore_logs
# Create FastAPI app
app = FastAPI(
title=settings.APP_NAME,
version=settings.APP_VERSION,
docs_url="/docs",
redoc_url="/redoc"
)
# Configure CORS
print("="*70)
print("FAMILY HUB - CORS CONFIGURATION")
print("="*70)
print(f"Allowed Origins: {settings.cors_origins}")
print("="*70)
app.add_middleware(
CORSMiddleware,
allow_origins=settings.cors_origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Mount static files for uploads
static_path = Path(__file__).parent / "static"
static_path.mkdir(exist_ok=True)
app.mount("/static", StaticFiles(directory=str(static_path)), name="static")
# Include routers
app.include_router(auth.router, prefix="/api/v1/auth", tags=["authentication"])
app.include_router(users.router, prefix="/api/v1/users", tags=["users"])
app.include_router(chores.router, prefix="/api/v1/chores", tags=["chores"])
app.include_router(chore_logs.router, prefix="/api/v1/chores", tags=["chore-logs"])
app.include_router(uploads.router, prefix="/api/v1/uploads", tags=["uploads"])
app.include_router(public.router, prefix="/api/v1/public", tags=["public"])
@app.get("/")
async def root():
"""Root endpoint."""
return {
"message": "Family Hub API",
"version": settings.APP_VERSION,
"docs": "/docs"
}
@app.get("/health")
async def health_check():
"""Health check endpoint."""
return {"status": "healthy"}