Refactor configuration system with centralized type-safe config package

- Create internal/config package with unified config structs and validation
- Abstract viper dependency behind config.Loader interface for better testability
- Replace manual config parsing and type assertions with type-safe loading
- Consolidate AuthConfig, SiteConfig, and DiscoveryConfig into single package
- Add comprehensive validation with clear error messages
- Remove ~200 lines of duplicate config handling code
- Maintain backward compatibility with existing config files
This commit is contained in:
2025-10-08 17:58:03 +02:00
parent 2959ecedf9
commit 38c2897ece
11 changed files with 550 additions and 332 deletions

View File

@@ -8,18 +8,12 @@ import (
"strings"
"sync"
"github.com/insertr/insertr/internal/config"
"github.com/insertr/insertr/internal/engine"
)
// SiteConfig represents configuration for a registered site
type SiteConfig struct {
SiteID string `yaml:"site_id"`
Path string `yaml:"path"` // Served path (enhanced output)
SourcePath string `yaml:"source_path"` // Source path (for enhancement)
Domain string `yaml:"domain,omitempty"`
AutoEnhance bool `yaml:"auto_enhance"`
Discovery *DiscoveryConfig `yaml:"discovery,omitempty"` // Override discovery settings
}
// Type alias for backward compatibility
type SiteConfig = config.SiteConfig
// SiteManager handles registration and enhancement of static sites
type SiteManager struct {