From fd95c2f8da0af833064eb144dd8d5a0168477ce1 Mon Sep 17 00:00:00 2001 From: Sandro Date: Tue, 27 Oct 2026 20:36:58 +0100 Subject: [PATCH] fix(api): add getThought endpoint and frontend api method to resolve docker tsc build error --- frontend/src/lib/api.ts | 4 ++++ internal/api/server.go | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index 2cd6369..4b63a4f 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -309,6 +309,10 @@ export const api = { return ensureArray(res); }, + async getThought(thoughtId: string): Promise { + return request(`/api/v1/thoughts/${encodeURIComponent(thoughtId)}`); + }, + async triageAction( thoughtId: string, action: 'keep' | 'discard' | 'restore', diff --git a/internal/api/server.go b/internal/api/server.go index 56b6561..637948e 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -88,6 +88,7 @@ func (s *Server) Router() http.Handler { // Instant Capture & Thoughts r.Post("/api/v1/inbox", s.handleCaptureInbox) r.Get("/api/v1/thoughts", s.handleGetThoughts) + r.Get("/api/v1/thoughts/{id}", s.handleGetThought) r.Patch("/api/v1/thoughts/{id}", s.handleUpdateThought) r.Delete("/api/v1/thoughts/{id}", s.handleDeleteThought) r.Delete("/api/v1/thoughts/discarded/purge", s.handlePurgeDiscarded) @@ -702,6 +703,17 @@ func (s *Server) handleGetThoughts(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusOK, thoughts) } +func (s *Server) handleGetThought(w http.ResponseWriter, r *http.Request) { + userID := auth.GetUserID(r.Context()) + thoughtID := chi.URLParam(r, "id") + thought, err := s.store.GetThoughtByID(userID, thoughtID) + if err != nil || thought == nil { + writeError(w, http.StatusNotFound, "Aufgabe nicht gefunden") + return + } + writeJSON(w, http.StatusOK, thought) +} + func (s *Server) handleGetTriageDeck(w http.ResponseWriter, r *http.Request) { userID := auth.GetUserID(r.Context()) thoughts, err := s.store.GetThoughts(userID, "inbox", 100)