config

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterRoutesWithAuth

func RegisterRoutesWithAuth(e *echo.Echo, cfg *Config, authMiddleware *auth.Middleware)

RegisterRoutesWithAuth registers config routes with authentication.

Types

type Config

type Config struct {
	// Database settings
	DatabaseConnectRetryCount int           `koanf:"database_connect_retry_count" json:"database_connect_retry_count"`
	DatabaseConnectRetryDelay time.Duration `koanf:"database_connect_retry_delay" json:"database_connect_retry_delay"`
	DatabaseDebug             bool          `koanf:"database_debug" json:"database_debug"`
	DatabaseFilePath          string        `koanf:"database_file_path" json:"database_file_path" validate:"required"`
	DatabaseBusyTimeout       time.Duration `koanf:"database_busy_timeout" json:"database_busy_timeout"`
	DatabaseMaxRetries        int           `koanf:"database_max_retries" json:"database_max_retries"`

	// Server settings
	ServerHost string `koanf:"server_host" json:"server_host"`
	ServerPort int    `koanf:"server_port" json:"server_port"`

	// Application settings
	SyncIntervalMinutes int `koanf:"sync_interval_minutes" json:"sync_interval_minutes"`
	WorkerProcesses     int `koanf:"worker_processes" json:"worker_processes"`

	// Job retention settings
	JobRetentionDays int `koanf:"job_retention_days" json:"job_retention_days"`

	// Cache settings
	CacheDir               string `koanf:"cache_dir" json:"cache_dir"`
	DownloadCacheMaxSizeGB int    `koanf:"download_cache_max_size_gb" json:"download_cache_max_size_gb"`

	// Plugin settings
	PluginDir string `koanf:"plugin_dir" json:"plugin_dir"`

	// Supplement discovery settings
	SupplementExcludePatterns []string `koanf:"supplement_exclude_patterns" json:"supplement_exclude_patterns"`

	// Authentication settings
	JWTSecret string `koanf:"jwt_secret" json:"-" validate:"required"` // Never expose in JSON

	// Environment settings
	// Set to "test" to enable test-only API endpoints (e.g., /test/users)
	Environment string `koanf:"environment" json:"environment"`

	// Internal settings (computed, not from config file)
	Hostname string `koanf:"-" json:"-"`

	// DevLibraryPath is the computed path to tmp/library in the main git repo.
	// Used by the frontend to create a default dev library.
	// Computed at startup, not from config file. Only set in development.
	DevLibraryPath string `koanf:"-" json:"dev_library_path,omitempty"`
}

Config holds all application configuration. Configure via YAML file (/config/shisho.yaml) or environment variables. Environment variables use uppercase with underscores (e.g., DATABASE_FILE_PATH).

func New

func New() (*Config, error)

New creates a new Config by loading from file and environment variables. Load order (later sources override earlier):

  1. Defaults
  2. Config file (/config/shisho.yaml or CONFIG_FILE env var)
  3. Environment variables (prefixed with SHISHO_)

func NewForTest

func NewForTest() *Config

NewForTest creates a Config for testing with minimal required fields.

func (*Config) DownloadCacheMaxSizeBytes

func (c *Config) DownloadCacheMaxSizeBytes() int64

DownloadCacheMaxSizeBytes returns the maximum cache size in bytes.

func (*Config) IsTestMode

func (c *Config) IsTestMode() bool

IsTestMode returns true if the server is running in test mode.

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(cfg *Config) *Service

func (*Service) RetrieveConfig

func (s *Service) RetrieveConfig() *Config

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL