
- Implement user authentication with JWT tokens - Add messaging system for sending/receiving messages - Create SQLite database with SQLAlchemy models - Set up Alembic for database migrations - Add health check endpoint - Include comprehensive API documentation - Support user registration, login, and message management - Enable conversation history and user listing
21 lines
570 B
Python
21 lines
570 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
from sqlalchemy import text
|
|
|
|
from app.db.session import get_db
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/health")
|
|
def health_check(db: Session = Depends(get_db)):
|
|
try:
|
|
db.execute(text("SELECT 1"))
|
|
database_status = "healthy"
|
|
except Exception as e:
|
|
database_status = f"unhealthy: {str(e)}"
|
|
|
|
return {
|
|
"status": "healthy" if database_status == "healthy" else "unhealthy",
|
|
"database": database_status,
|
|
"service": "Simple Messaging App"
|
|
} |