Files
Jānis Kacēns 5199c1fa16 Phase 4: upload, LLM extraction, import review flow
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 13:15:04 +03:00

56 lines
1.1 KiB
Go

package config
import (
"os"
"strings"
)
type Config struct {
OpenAIAPIKey string
SessionSecret string
DataDir string
Port string
AdminUsers []AdminUser
LLMModel string // defaults to gpt-4o-mini
}
type AdminUser struct {
Name string
Password string
}
func Load() *Config {
cfg := &Config{
OpenAIAPIKey: os.Getenv("OPENAI_API_KEY"),
SessionSecret: os.Getenv("SESSION_SECRET"),
DataDir: envOr("DATA_DIR", "./data"),
Port: envOr("PORT", "8079"),
LLMModel: envOr("LLM_MODEL", "gpt-4o-mini"),
}
cfg.AdminUsers = parseAdminUsers(os.Getenv("ADMIN_USERS"))
return cfg
}
func envOr(key, def string) string {
if v := os.Getenv(key); v != "" {
return v
}
return def
}
func parseAdminUsers(raw string) []AdminUser {
if raw == "" {
return nil
}
var users []AdminUser
for _, pair := range strings.Split(raw, ",") {
pair = strings.TrimSpace(pair)
name, pass, ok := strings.Cut(pair, ":")
if !ok || name == "" || pass == "" {
continue
}
users = append(users, AdminUser{Name: name, Password: pass})
}
return users
}