package router

import (
	"bookhoard/internal/handlers"
)

func registerSystemRoutes(cfg *Config) {
	e := cfg.Echo

	// JWT middleware
	jwtMiddleware := createJWTMiddleware(cfg)

	// Protected routes (admin-only)
	protected := e.Group("/api", jwtMiddleware)
	system := protected.Group("/system", handlers.AdminMiddleware)

	// System configuration routes (admin-only)
	system.GET("/config", cfg.SidecarHandler.GetSystemConfiguration)
	system.PUT("/config", cfg.SidecarHandler.UpdateSystemConfiguration)

	// Unified tunable settings (admin-only). These back the admin UI's
	// editable System Settings sections and supersede the legacy
	// /api/libraries/scan-settings JSON routes.
	system.GET("/settings", cfg.SystemSettingsHandler.GetSettings)
	system.PUT("/settings", cfg.SystemSettingsHandler.UpdateSetting)
}
