
This commit includes: - Project structure and configuration - Database models for tasks, users, and categories - Authentication system with JWT - CRUD endpoints for tasks and categories - Search, filter, and sorting functionality - Health check endpoint - Alembic migration setup - Documentation
37 lines
873 B
Python
37 lines
873 B
Python
from typing import Any
|
|
|
|
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.core.database import get_db
|
|
from app.core.deps import get_current_active_user
|
|
from app.crud.user import update_user
|
|
from app.models.user import User as UserModel
|
|
from app.schemas.user import User, UserUpdate
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/me", response_model=User)
|
|
def read_current_user(
|
|
current_user: UserModel = Depends(get_current_active_user),
|
|
) -> Any:
|
|
"""
|
|
Get current user.
|
|
"""
|
|
return current_user
|
|
|
|
|
|
@router.put("/me", response_model=User)
|
|
def update_current_user(
|
|
*,
|
|
db: Session = Depends(get_db),
|
|
user_in: UserUpdate,
|
|
current_user: UserModel = Depends(get_current_active_user),
|
|
) -> Any:
|
|
"""
|
|
Update current user.
|
|
"""
|
|
user = update_user(db, user_id=current_user.id, user_in=user_in)
|
|
return user
|