kv-netflix/backend/internal/config/config.go
vndangkhoa 056824cfa8 Refactor: Clean up codebase and improve project structure
- Remove debug files, binaries, and temp outputs from repo
- Update .gitignore to exclude cache, logs, and build artifacts
- Fix CI/CD workflow for Go backend (was referencing Python)
- Add graceful shutdown and config module to backend
- Add SSRF protection with URL validation
- Refactor handlers to reduce code duplication
- Add React ErrorBoundary component
- Add lazy loading for frontend routes
- Setup Vitest for frontend testing
- Update Dockerfile to use Go 1.23
2026-02-18 19:00:22 +07:00

47 lines
922 B
Go

package config
import (
"os"
"strconv"
)
type Config struct {
Port string
DatabaseURL string
TMDBAPIKey string
GINMode string
AllowedOrigins []string
}
func Load() *Config {
return &Config{
Port: getEnv("PORT", "8000"),
DatabaseURL: getEnv("DATABASE_URL", "streamflow.db"),
TMDBAPIKey: os.Getenv("TMDB_API_KEY"),
GINMode: getEnv("GIN_MODE", "debug"),
AllowedOrigins: getEnvSlice("ALLOWED_ORIGINS", []string{"*"}),
}
}
func getEnv(key, fallback string) string {
if val := os.Getenv(key); val != "" {
return val
}
return fallback
}
func getEnvSlice(key string, fallback []string) []string {
if val := os.Getenv(key); val != "" {
return []string{val}
}
return fallback
}
func getEnvInt(key string, fallback int) int {
if val := os.Getenv(key); val != "" {
if i, err := strconv.Atoi(val); err == nil {
return i
}
}
return fallback
}