package config

import (
	"os"
)

type Config struct {
	DSN        string // e.g. mysql: "user:pass@tcp(127.0.0.1:3306)/mind?parseTime=true"; sqlite: "file:mind.db?_pragma=busy_timeout(5000)"
	Driver     string // "mysql" or "sqlite"
	JWTSecret  string
	Port       string // default 8080
}

func getenv(k, def string) string { v := os.Getenv(k); if v == "" { return def }; return v }

func Load() Config {
	return Config{
		DSN:       getenv("DB_DSN", "file:mind.db?_pragma=busy_timeout(5000)"),
		Driver:    getenv("DB_DRIVER", "sqlite"),
		JWTSecret: getenv("JWT_SECRET", "devsecret"),
		Port:      getenv("PORT", "8080"),
	}
}
