8a4029058b
Add demo dashboard settings table and CRUD API * Add demo dashboard settings table and CRUD API - Migration 00000000000123: create demoDashboardSettings table (id, guid, key, value JSONB, isDeleted, timestamps) - SQLC queries and repository for create, list, listByGuid, get, update, soft delete - OpenAPI paths and schemas in queryAPI.yaml; regenerate api.gen.go (embedded spec) - Handlers in api/queryAPI/demodashboardsettings.go; ConfigProvider GetDBQueries for repo access - Unit tests for demo dashboard settings CRUD * Fix sqlc-generated demo dashboard setting types Align demo dashboard settings handlers with sqlc output (DemoDashboardSetting model + pointer slices) so CI codegen/build succeeds. * Fix CI gosec and gofmt issues - Suppress gosec G115 for TotalCount len->int32 cast (consistent with other list endpoints) - gofmt mock GetDBQueries() in test helpers * gofmt query API demo settings * Tighten demo dashboard settings OpenAPI constraints * Regenerate query API embedded spec * refactor: generic UI settings (table, API, service) and three-layer architecture - Replace demo-dashboard-settings with generic UI settings: - Table uiSettings with namespace (was guid), key, value JSONB; UNIQUE(namespace, key) - Migration 123: create_ui_settings (single migration, no rename) - OpenAPI: /ui-settings, UISettingsService, UISetting schemas with namespace - API types and handlers: CreateUISetting, ListUISettings, GetUISetting, UpdateUISetting, DeleteUISetting - Add service layer (architecture fix): - internal/uisettings: Service with Create, List, ListByNamespace, Get, Update, SoftDelete - Controllers call s.svc.UISettings only; remove GetDBQueries from queryAPI ConfigProvider - Wire UISettings in Services, main.go, and testutils - Repository: uisettings.sql + uisettings.sql.go, UISetting model; remove demodashboardsettings - Controller: uisettings.go (replaces demodashboardsettings.go), ErrNotFound from uisettings package - Tests: uisettings_test.go with namespace-based list/cre… * Add UISetting model and generated queries for uiSettings table - models.go: add UISetting struct (sqlc 1.30.0) - uisettings.sql.go: generated CRUD for ui_settings feature Made-with: Cursor * Use repository.UiSetting to match sqlc-generated type - service and API use repository.UiSetting (sqlc struct name for uiSettings table) - uisettings.sql.go: keep CreateUISetting/GetUISetting etc. from query names, return *UiSetting - Fixes Docker/CI build undefined repository.UISetting * Fix import formatting for golangci-lint * Lint fix * uisettings list test * tests fixes * Merge main: resolve api.gen.go conflicts (UI settings + DeleteDocument) * Doc updates and elimination of index redundancy Approved-by: Jay Brown
Api related artifacts
Prometheus metrics
Prometheus metrics are exposed for all api endpoints automatically at the standard /metrics endpoint. (http://localhost:8080/metrics)
Swagger API documentation
Automatic API docs are generated and exposed for all routes at http://localhost:8080/swagger/index.html when the api server is running.
Logging
Structured logging is built into all API routes automatically.
So for example here is a what a few API hits on queryAPI look like in the logs when using text (as opposed to json)
____ __
/ __/___/ / ___
/ _// __/ _ \/ _ \
/___/\__/_//_/\___/ v4.13.3
High performance, minimalist Go web framework
https://echo.labstack.com
____________________________________O/_______
O\
⇨ http server started on [::]:8080
time=2025-02-05T13:38:32.484-08:00 level=INFO msg="HTTP request" method=GET uri=/metrics status=200 latency=2.713792ms error=<nil> remote_ip=::1
time=2025-02-05T13:38:39.792-08:00 level=INFO msg="HTTP request" method=GET uri=/swagger/index.html status=200 latency=490.625µs error=<nil> remote_ip=::1
time=2025-02-05T13:38:39.803-08:00 level=INFO msg="HTTP request" method=GET uri=/swagger/swagger-ui.css status=200 latency=738.083µs error=<nil> remote_ip=::1
time=2025-02-05T13:38:39.805-08:00 level=INFO msg="HTTP request" method=GET uri=/swagger/swagger-ui-standalone-preset.js status=200 latency=887.875µs error=<nil> remote_ip=::1
time=2025-02-05T13:38:39.807-08:00 level=INFO msg="HTTP request" method=GET uri=/swagger/swagger-ui-bundle.js status=200 latency=3.854042ms error=<nil> remote_ip=::1
time=2025-02-05T13:38:39.871-08:00 level=INFO msg="HTTP request" method=GET uri=/swagger/doc.json status=200 latency=1.163167ms error=<nil> remote_ip=::1
time=2025-02-05T13:38:39.871-08:00 level=INFO msg="HTTP request" method=GET uri=/swagger/favicon-32x32.png status=200 latency=60.875µs error=<nil> remote_ip=::1