// Package config provides configuration management for the container-mom application
package config

import (
	"os"
)

// Config holds the application configuration
type Config struct {
	ListenAddr          string
	StripeKey           string
	StripeWebhookSecret string
	MongoURI            string
}

// LoadConfig loads configuration from the given path
func LoadConfig(_ string) (*Config, error) {
	// TODO: Implement proper config loading from file
	return &Config{
		ListenAddr:          getEnvOrDefault("LISTEN_ADDR", ":8080"),
		StripeKey:           os.Getenv("STRIPE_KEY"),
		StripeWebhookSecret: os.Getenv("STRIPE_WEBHOOK_SECRET"),
		MongoURI:            os.Getenv("MONGODB_URI"),
	}, nil
}

// Load is an alias for LoadConfig with default path
func Load() (*Config, error) {
	return LoadConfig("config.yaml")
}

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