Now that KanzlAI is on the youpc.org Supabase instance, the separate YouPCDatabaseURL connection is unnecessary. The main database connection can query mlex.* tables directly since they're on the same Postgres. - Remove YouPCDatabaseURL from config - Remove separate sqlx.Connect block in main.go - Pass main database handle as youpcDB parameter to router - Update CLAUDE.md: mgmt schema in youpc.org (was kanzlai in flexsiebels)
47 lines
1.0 KiB
Go
47 lines
1.0 KiB
Go
package config
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
)
|
|
|
|
type Config struct {
|
|
Port string
|
|
DatabaseURL string
|
|
SupabaseURL string
|
|
SupabaseAnonKey string
|
|
SupabaseServiceKey string
|
|
SupabaseJWTSecret string
|
|
AnthropicAPIKey string
|
|
FrontendOrigin string
|
|
}
|
|
|
|
func Load() (*Config, error) {
|
|
cfg := &Config{
|
|
Port: getEnv("PORT", "8080"),
|
|
DatabaseURL: os.Getenv("DATABASE_URL"),
|
|
SupabaseURL: os.Getenv("SUPABASE_URL"),
|
|
SupabaseAnonKey: os.Getenv("SUPABASE_ANON_KEY"),
|
|
SupabaseServiceKey: os.Getenv("SUPABASE_SERVICE_KEY"),
|
|
SupabaseJWTSecret: os.Getenv("SUPABASE_JWT_SECRET"),
|
|
AnthropicAPIKey: os.Getenv("ANTHROPIC_API_KEY"),
|
|
FrontendOrigin: getEnv("FRONTEND_ORIGIN", "https://kanzlai.msbls.de"),
|
|
}
|
|
|
|
if cfg.DatabaseURL == "" {
|
|
return nil, fmt.Errorf("DATABASE_URL is required")
|
|
}
|
|
if cfg.SupabaseJWTSecret == "" {
|
|
return nil, fmt.Errorf("SUPABASE_JWT_SECRET is required")
|
|
}
|
|
|
|
return cfg, nil
|
|
}
|
|
|
|
func getEnv(key, fallback string) string {
|
|
if v := os.Getenv(key); v != "" {
|
|
return v
|
|
}
|
|
return fallback
|
|
}
|