
- Add user authentication with JWT tokens - Implement task CRUD operations with status and priority - Set up SQLite database with SQLAlchemy ORM - Create Alembic migrations for database schema - Add comprehensive API documentation - Include health check endpoint and CORS configuration - Structure codebase with proper separation of concerns
24 lines
738 B
Python
24 lines
738 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
from app.db.session import get_db
|
|
from app.schemas.user import User, UserUpdate
|
|
from app.services.user import update_user
|
|
from app.core.auth import get_current_active_user
|
|
from app.models.user import User as UserModel
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/me", response_model=User)
|
|
def read_current_user(current_user: UserModel = Depends(get_current_active_user)):
|
|
return current_user
|
|
|
|
|
|
@router.put("/me", response_model=User)
|
|
def update_current_user(
|
|
user_update: UserUpdate,
|
|
current_user: UserModel = Depends(get_current_active_user),
|
|
db: Session = Depends(get_db),
|
|
):
|
|
return update_user(db, user_id=current_user.id, user_update=user_update)
|