Files
pulse-api/internal/config/config.go

37 lines
952 B
Go

package config
import (
"os"
)
type Config struct {
DatabaseURL string
JWTSecret string
Port string
ResendAPIKey string
FromEmail string
FromName string
AppURL string
TelegramBotToken string
}
func Load() *Config {
return &Config{
DatabaseURL: getEnv("DATABASE_URL", "postgres://homelab:homelab@db:5432/homelab?sslmode=disable"),
JWTSecret: getEnv("JWT_SECRET", "change-me-in-production"),
Port: getEnv("PORT", "8080"),
ResendAPIKey: getEnv("RESEND_API_KEY", ""),
FromEmail: getEnv("FROM_EMAIL", "noreply@digital-home.site"),
FromName: getEnv("FROM_NAME", "Homelab"),
AppURL: getEnv("APP_URL", "https://api.digital-home.site"),
TelegramBotToken: getEnv("TELEGRAM_BOT_TOKEN", ""),
}
}
func getEnv(key, defaultValue string) string {
if value := os.Getenv(key); value != "" {
return value
}
return defaultValue
}