Initial scaffold: backend base + docker-compose dev infra + sveltekit frontend
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
// Package config carga la configuración del backend desde variables de entorno.
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/caarlos0/env/v11"
|
||||
)
|
||||
|
||||
// Config agrupa toda la configuración del servidor. Los campos de Zitadel/S3
|
||||
// ya están definidos aunque todavía no se usen: se conectan en las siguientes
|
||||
// fases sin tener que tocar esta struct de nuevo.
|
||||
type Config struct {
|
||||
Env string `env:"APP_ENV" envDefault:"development"`
|
||||
Port int `env:"PORT" envDefault:"8080"`
|
||||
|
||||
// Orígenes permitidos para CORS en desarrollo (el frontend en Vite corre en otro puerto).
|
||||
CORSAllowedOrigins []string `env:"CORS_ALLOWED_ORIGINS" envSeparator:"," envDefault:"http://localhost:5173"`
|
||||
|
||||
DatabaseURL string `env:"DATABASE_URL" envDefault:"postgres://dockermanager:dockermanager@localhost:5432/dockermanager?sslmode=disable"`
|
||||
|
||||
ZitadelIssuer string `env:"ZITADEL_ISSUER"`
|
||||
ZitadelClientID string `env:"ZITADEL_CLIENT_ID"`
|
||||
ZitadelClientSecret string `env:"ZITADEL_CLIENT_SECRET"`
|
||||
SessionSecret string `env:"SESSION_SECRET" envDefault:"dev-insecure-secret-change-me"`
|
||||
|
||||
S3Endpoint string `env:"S3_ENDPOINT" envDefault:"http://localhost:8333"`
|
||||
S3Bucket string `env:"S3_BUCKET" envDefault:"dockermanager"`
|
||||
S3AccessKey string `env:"S3_ACCESS_KEY"`
|
||||
S3SecretKey string `env:"S3_SECRET_KEY"`
|
||||
|
||||
// DockerHost vacío = usar el socket por defecto del sistema (DOCKER_HOST estándar del SDK).
|
||||
DockerHost string `env:"DOCKER_HOST"`
|
||||
}
|
||||
|
||||
// Load lee la configuración desde el entorno del proceso.
|
||||
func Load() (Config, error) {
|
||||
cfg := Config{}
|
||||
if err := env.Parse(&cfg); err != nil {
|
||||
return Config{}, fmt.Errorf("parsing config: %w", err)
|
||||
}
|
||||
return cfg, nil
|
||||
}
|
||||
Reference in New Issue
Block a user