CUB-127: implement Control Center CRUD API in Go
Some checks failed
Dev Build / build-test (pull_request) Failing after 11m6s
Dev Build / build-test (push) Successful in 1m54s

This commit is contained in:
2026-05-06 17:29:44 -04:00
parent ab19a7ccde
commit cce3e061a7
16 changed files with 1523 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
// Package config provides application configuration loaded from environment
// variables with sensible defaults for local development.
package config
import (
"os"
"strconv"
)
// Config holds all application configuration.
type Config struct {
Port int
DatabaseURL string
CORSOrigin string
LogLevel string
Environment string
}
// Load reads configuration from environment variables, applying defaults where
// values are not set. All secrets come from the environment — nothing is hardcoded.
func Load() *Config {
return &Config{
Port: getEnvInt("PORT", 8080),
DatabaseURL: getEnv("DATABASE_URL", "postgres://controlcenter:controlcenter@localhost:5432/controlcenter?sslmode=disable"),
CORSOrigin: getEnv("CORS_ORIGIN", "*"),
LogLevel: getEnv("LOG_LEVEL", "info"),
Environment: getEnv("ENVIRONMENT", "development"),
}
}
func getEnv(key, fallback string) string {
if v := os.Getenv(key); v != "" {
return v
}
return fallback
}
func getEnvInt(key string, fallback int) int {
if v := os.Getenv(key); v != "" {
if i, err := strconv.Atoi(v); err == nil {
return i
}
}
return fallback
}