bd28b60338
- Uppdatera robust_client.go med rätt tabellnamn (boc_chart_of_accounts, boc_journal_lines, boc_journal_entries) - Uppdatera kolumnnamn (entry_id istället för journal_entry_id, account_code istället för code) - Hantera både stora och små bokstäver för account_type - Lägg till ledgerApi i frontend med BalanceSheet, IncomeStatement, MomsReport - Uppdatera DashboardPage med Ledger KPI-kort - Lägg till LEDGER_DB_URL i docker-compose.yml - Uppdatera Dockerfile till golang:1.25-alpine
69 lines
1.9 KiB
Go
69 lines
1.9 KiB
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
type Config struct {
|
|
Port string
|
|
DBURL string
|
|
LedgerDBURL string
|
|
JWTSecret string
|
|
AMOSBaseURL string
|
|
CORSOrigins []string
|
|
MigrationsDir string
|
|
RustServiceURL string
|
|
RedisURL string
|
|
RedisAddr string
|
|
KafkaBrokers []string
|
|
ResendAPIKey string
|
|
FromEmail string
|
|
FromName string
|
|
}
|
|
|
|
func Load() *Config {
|
|
return &Config{
|
|
Port: getEnv("PORT", "9092"),
|
|
DBURL: getEnv("DB_URL", "postgres://boc:boc@localhost:5432/boc?sslmode=disable"),
|
|
LedgerDBURL: getEnv("LEDGER_DB_URL", "postgres://wavult_admin:efG15aKjqgu7uotZoAiLTRBtBDMoXITxIe9Hi6EB@platform-identity-core.cvi0qcksmsfj.eu-north-1.rds.amazonaws.com:5432/amos?sslmode=disable"),
|
|
JWTSecret: getEnv("JWT_SECRET", "w+Qkf/CoDda3Ba7vZLKokrGHiwUV5Ak/3tiBmFAvRC8="),
|
|
AMOSBaseURL: getEnv("AMOS_BASE_URL", "http://localhost:9000"),
|
|
CORSOrigins: splitComma(getEnv("CORS_ORIGINS", "http://localhost:3000")),
|
|
MigrationsDir: getEnv("MIGRATIONS_DIR", "./db/migrations"),
|
|
RustServiceURL: getEnv("RUST_SERVICE_URL", "http://localhost:9093"),
|
|
RedisURL: getEnv("REDIS_URL", "redis://localhost:6379"),
|
|
RedisAddr: getEnv("REDIS_ADDR", "localhost:6379"),
|
|
KafkaBrokers: splitComma(getEnv("KAFKA_BROKERS", "localhost:9092")),
|
|
ResendAPIKey: getEnv("RESEND_API_KEY", ""),
|
|
FromEmail: getEnv("FROM_EMAIL", "noreply@landvex.com"),
|
|
FromName: getEnv("FROM_NAME", "Landvex BOC"),
|
|
}
|
|
}
|
|
|
|
func getEnv(key, fallback string) string {
|
|
if v := os.Getenv(key); v != "" {
|
|
return v
|
|
}
|
|
return fallback
|
|
}
|
|
|
|
func requireEnv(key string) string {
|
|
v := os.Getenv(key)
|
|
if v == "" {
|
|
panic("required environment variable not set: " + key)
|
|
}
|
|
return v
|
|
}
|
|
|
|
func splitComma(s string) []string {
|
|
parts := strings.Split(s, ",")
|
|
out := make([]string, 0, len(parts))
|
|
for _, p := range parts {
|
|
if t := strings.TrimSpace(p); t != "" {
|
|
out = append(out, t)
|
|
}
|
|
}
|
|
return out
|
|
}
|