feat(api): add setup_complete system setting and status handlers

Add 'setup_complete' boolean to the system_settings seed data (defaults
to false) so fresh databases start in the unconfigured state.

Add two new handlers to SystemSettingsHandler:
- SetSetupComplete: marks setup_complete=true in the database
- GetSetupStatus: reads the current setup_complete value, returns
  {setup_complete: bool} JSON response, defaults to false if the
  setting row is missing or unparseable
This commit is contained in:
2026-06-06 00:03:52 -04:00
parent 307a43f6b0
commit cea8e64da2
2 changed files with 28 additions and 1 deletions
+2 -1
View File
@@ -49,7 +49,8 @@ CREATE TABLE IF NOT EXISTS system_settings (
INSERT INTO system_settings (setting_key, setting_value, description) VALUES
('scan_poll_interval_seconds', '60', 'How often to scan all libraries in minutes'),
('auto_scan_enabled', 'true', 'Whether auto-scanning is enabled system-wide'),
('default_timezone', 'UTC', 'System default timezone')
('default_timezone', 'UTC', 'System default timezone'),
('setup_complete', 'false', 'Whether the initial setup wizard has been completed')
ON CONFLICT (setting_key) DO NOTHING;
-- Create refresh_tokens table
+26
View File
@@ -95,6 +95,32 @@ func (h *SystemSettingsHandler) UpdateScanSettings(c *echo.Context) error {
})
}
func (h *SystemSettingsHandler) SetSetupComplete(c *echo.Context) error {
err := h.db.UpdateSystemSetting(c.Request().Context(), database.UpdateSystemSettingParams{
SettingKey: "setup_complete",
SettingValue: "true",
})
if err != nil {
return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
}
return c.JSON(http.StatusOK, map[string]string{"message": "setup complete"})
}
func (h *SystemSettingsHandler) GetSetupStatus(c *echo.Context) error {
val, err := h.db.GetSystemSetting(c.Request().Context(), "setup_complete")
if err != nil {
if errors.Is(err, pgx.ErrNoRows) {
return c.JSON(http.StatusOK, map[string]bool{"setup_complete": false})
}
return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
}
complete, err := strconv.ParseBool(val)
if err != nil {
complete = false
}
return c.JSON(http.StatusOK, map[string]bool{"setup_complete": complete})
}
func (h *SystemSettingsHandler) GetScanSettings(c *echo.Context) error {
scanFrequencySetting, err := h.db.GetSystemSetting(c.Request().Context(), "scan_poll_interval_seconds")
if err != nil {