
- Set up FastAPI application with CORS and proper structure - Created User model with SQLAlchemy and SQLite database - Implemented JWT-based authentication with bcrypt password hashing - Added user registration, login, and profile endpoints - Created health check endpoint for monitoring - Set up Alembic for database migrations - Added comprehensive API documentation - Configured proper project structure with separate modules - Updated README with complete setup and usage instructions
23 lines
670 B
Python
23 lines
670 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
from sqlalchemy import text
|
|
from app.db.session import get_db
|
|
import datetime
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/health")
|
|
async def health_check(db: Session = Depends(get_db)):
|
|
try:
|
|
# Test database connection
|
|
db.execute(text("SELECT 1"))
|
|
db_status = "healthy"
|
|
except Exception as e:
|
|
db_status = f"unhealthy: {str(e)}"
|
|
|
|
return {
|
|
"status": "healthy" if db_status == "healthy" else "unhealthy",
|
|
"timestamp": datetime.datetime.utcnow().isoformat(),
|
|
"database": db_status,
|
|
"service": "User Authentication Service"
|
|
} |