2025-05-16 14:34:27 +00:00

34 lines
944 B
Python

import uvicorn
from fastapi import FastAPI, Depends
from sqlalchemy.orm import Session
from app.core.config import settings
from app.core.database import get_db
from app.api.api import api_router
app = FastAPI(
title=settings.PROJECT_NAME,
openapi_url=f"{settings.API_V1_STR}/openapi.json"
)
# Include routers
app.include_router(api_router, prefix=settings.API_V1_STR)
# Health check endpoint
@app.get("/health", tags=["health"])
async def health(db: Session = Depends(get_db)):
"""Health check endpoint that verifies API and database connectivity."""
try:
# Verify the database connection
db.execute("SELECT 1")
db_status = "ok"
except Exception as e:
db_status = f"error: {str(e)}"
return {
"status": "ok",
"database": db_status,
"api_version": "1.0.0"
}
if __name__ == "__main__":
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True)