72 lines
2.0 KiB
Python
72 lines
2.0 KiB
Python
"""Main FastAPI application."""
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
<<<<<<< HEAD
|
|
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
|
|
=======
|
|
from app.core.config import settings
|
|
from app.api.v1 import auth, users, chores
|
|
>>>>>>> 65c71b3d67d462fe9ecc01a1c2aa17e54b626fe2
|
|
|
|
# Create FastAPI app
|
|
app = FastAPI(
|
|
title=settings.APP_NAME,
|
|
version=settings.APP_VERSION,
|
|
docs_url="/docs",
|
|
redoc_url="/redoc"
|
|
)
|
|
|
|
# Configure CORS
|
|
<<<<<<< HEAD
|
|
print("="*70)
|
|
print("FAMILY HUB - CORS CONFIGURATION")
|
|
print("="*70)
|
|
print(f"Allowed Origins: {settings.cors_origins}")
|
|
print("="*70)
|
|
|
|
=======
|
|
>>>>>>> 65c71b3d67d462fe9ecc01a1c2aa17e54b626fe2
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.cors_origins,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
<<<<<<< HEAD
|
|
# 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")
|
|
|
|
=======
|
|
>>>>>>> 65c71b3d67d462fe9ecc01a1c2aa17e54b626fe2
|
|
# 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"])
|
|
<<<<<<< HEAD
|
|
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"])
|
|
=======
|
|
>>>>>>> 65c71b3d67d462fe9ecc01a1c2aa17e54b626fe2
|
|
|
|
@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"}
|