Initial commit: Homelab API
This commit is contained in:
34
internal/config/config.go
Normal file
34
internal/config/config.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user