using System.Collections.Specialized;
using System.Text.Json;

namespace DragonISO.App.Services;

// /notes/* route handlers â€” append-only operator show-notes file.
//
//   POST /notes (body: { "text": "..." })  â†’ AppendNote
public sealed partial class ControlSurfaceServer
{
    private object AppendNote(JsonElement body, NameValueCollection query)
    {
        var text = TryGetString(body, query, "text");
        if (string.IsNullOrWhiteSpace(text))
            return new { ok = false, error = "text required" };
        var ok = NotesService.Append(text);
        return new { ok, action = "note", path = NotesService.TodayPath };
    }
}
