package config

import (
	"os"
)

type Config struct {
	Port        string
	MongoDBURI  string
	DBName      string
	JWTSecret   string
	Environment string
	CertsPath   string
}

func LoadConfig() *Config {
	return &Config{
		Port:        getEnv("PORT", "8080"),
		MongoDBURI:  getEnv("MONGODB_URI", "mongodb://localhost:27017"),
		DBName:      getEnv("DB_NAME", "pki_db"),
		JWTSecret:   getEnv("JWT_SECRET", "your-secret-key"),
		Environment: getEnv("ENVIRONMENT", "development"),
		CertsPath:   getEnv("CERTS_PATH", "./certs"),
	}
}

func getEnv(key, defaultValue string) string {
	if value := os.Getenv(key); value != "" {
		return value
	}
	return defaultValue
}
