
- Set up project structure with FastAPI - Implement SQLAlchemy models for User and Task - Create Alembic migrations - Implement authentication with JWT - Add CRUD operations for tasks - Add task filtering and prioritization - Configure health check endpoint - Update README with project documentation
34 lines
773 B
Python
34 lines
773 B
Python
from typing import Any
|
|
|
|
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app import crud, models, schemas
|
|
from app.api.api_v1 import deps
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/me", response_model=schemas.User)
|
|
async def read_user_me(
|
|
current_user: models.User = Depends(deps.get_current_active_user),
|
|
) -> Any:
|
|
"""
|
|
Get current user.
|
|
"""
|
|
return current_user
|
|
|
|
|
|
@router.patch("/me", response_model=schemas.User)
|
|
async def update_user_me(
|
|
*,
|
|
db: Session = Depends(deps.get_db),
|
|
user_in: schemas.UserUpdate,
|
|
current_user: models.User = Depends(deps.get_current_active_user),
|
|
) -> Any:
|
|
"""
|
|
Update current user.
|
|
"""
|
|
user = crud.user.update(db, db_obj=current_user, obj_in=user_in)
|
|
return user
|