API: Add GET /api/items/by-uuid/{uuid} endpoint #43

Closed
opened 2026-02-09 00:16:00 +00:00 by forbes · 0 comments
Owner

Summary

Add a new endpoint to resolve a Silo item UUID to its full item response. This is needed by the silo-mod BOM sync feature — FreeCAD documents store the item's UUID as a custom property (SiloUUID), and the client needs to resolve that to a part number before submitting a BOM merge.

Endpoint

GET /api/items/by-uuid/{uuid}

Response: Same ItemResponse JSON as GET /api/items/{partNumber}.

Errors:

  • 404 if UUID not found or item is archived
  • 400 if UUID format is invalid

Implementation

Database layer (internal/db/items.go)

ItemRepository already has GetByID(ctx, id string) which queries by UUID primary key. This can be reused directly — the item's id column IS the stable UUID.

Handler (internal/api/handlers.go)

New handler HandleGetItemByUUID:

  1. Extract {uuid} from URL via chi.URLParam(r, "uuid")
  2. Validate UUID format
  3. Call s.queries.Items.GetByID(ctx, uuid)
  4. Return same ItemResponse as HandleGetItem

Route (internal/api/routes.go)

Register in the viewer-accessible /api group:

r.Get("/items/by-uuid/{uuid}", server.HandleGetItemByUUID)

Notes

  • The item id column (UUID) is the stable identifier across revisions — this is exactly what silo-mod stores as SiloUUID
  • No new DB query needed; GetByID already does this
  • Viewer role is sufficient (read-only lookup)
## Summary Add a new endpoint to resolve a Silo item UUID to its full item response. This is needed by the silo-mod BOM sync feature — FreeCAD documents store the item's UUID as a custom property (`SiloUUID`), and the client needs to resolve that to a part number before submitting a BOM merge. ## Endpoint ``` GET /api/items/by-uuid/{uuid} ``` **Response:** Same `ItemResponse` JSON as `GET /api/items/{partNumber}`. **Errors:** - `404` if UUID not found or item is archived - `400` if UUID format is invalid ## Implementation ### Database layer (`internal/db/items.go`) `ItemRepository` already has `GetByID(ctx, id string)` which queries by UUID primary key. This can be reused directly — the item's `id` column IS the stable UUID. ### Handler (`internal/api/handlers.go`) New handler `HandleGetItemByUUID`: 1. Extract `{uuid}` from URL via `chi.URLParam(r, "uuid")` 2. Validate UUID format 3. Call `s.queries.Items.GetByID(ctx, uuid)` 4. Return same `ItemResponse` as `HandleGetItem` ### Route (`internal/api/routes.go`) Register in the viewer-accessible `/api` group: ```go r.Get("/items/by-uuid/{uuid}", server.HandleGetItemByUUID) ``` ## Notes - The item `id` column (UUID) is the stable identifier across revisions — this is exactly what silo-mod stores as `SiloUUID` - No new DB query needed; `GetByID` already does this - Viewer role is sufficient (read-only lookup)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: kindred/silo#43