Spaces:
Running
Running
File size: 864 Bytes
7402e0f 2fa91ca 7402e0f 2fa91ca 7402e0f 2fa91ca |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
from fastapi import APIRouter, HTTPException
from pydantic import BaseModel
from typing import Optional
from app.services.note_store import get_note, update_note
from app.utils.time import now_ts
router = APIRouter(prefix="/notes", tags=["notes"])
class UpdateNoteRequest(BaseModel):
folder_id: Optional[str] = None
title: Optional[str] = None
@router.patch("/{note_id}")
def update_note_api(note_id: str, req: UpdateNoteRequest):
note = get_note(note_id)
if not note:
raise HTTPException(status_code=404, detail="Note not found")
updates = req.dict(exclude_unset=True)
if not updates:
return {"note_id": note_id, "updated": False}
updates["updated_at"] = now_ts()
update_note(note_id, updates)
return {
"note_id": note_id,
"updated": True,
"fields": list(updates.keys()),
}
|