Initial commit: Homelab API

This commit is contained in:
Cosmo
2026-02-06 11:19:55 +00:00
commit 5a40127edd
26 changed files with 2807 additions and 0 deletions

34
internal/config/config.go Normal file
View File

@@ -0,0 +1,34 @@
package config
import (
"os"
)
type Config struct {
DatabaseURL string
JWTSecret string
Port string
ResendAPIKey string
FromEmail string
FromName string
AppURL 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"),
}
}
func getEnv(key, defaultValue string) string {
if value := os.Getenv(key); value != "" {
return value
}
return defaultValue
}