This commit is contained in:
@@ -10,6 +10,8 @@ import (
|
||||
"gardomatic.kleiax.de/internal/api"
|
||||
"gardomatic.kleiax.de/internal/mailer"
|
||||
"gardomatic.kleiax.de/internal/platform/environment"
|
||||
"gardomatic.kleiax.de/internal/platform/validate"
|
||||
"gardomatic.kleiax.de/internal/storage"
|
||||
)
|
||||
|
||||
func configFromEnvironment() (api.Config, error) {
|
||||
@@ -55,6 +57,9 @@ func configFromEnvironment() (api.Config, error) {
|
||||
Port: integer("GARDOMATIC_API_PORT", 4000),
|
||||
Env: environment.String("GARDOMATIC_ENV", "development"),
|
||||
WebBaseURL: environment.String("GARDOMATIC_WEB_BASE_URL", "http://localhost:4040"),
|
||||
DemoAccountEmail: strings.ToLower(strings.TrimSpace(
|
||||
environment.String("GARDOMATIC_DEMO_ACCOUNT_EMAIL", ""),
|
||||
)),
|
||||
DB: api.DatabaseConfig{
|
||||
Dsn: required("GARDOMATIC_DB_DSN"), MaxOpenConns: integer("GARDOMATIC_DB_MAX_OPEN_CONNS", 25),
|
||||
MaxIdleConns: integer("GARDOMATIC_DB_MAX_IDLE_CONNS", 25), MaxIdleTime: duration("GARDOMATIC_DB_MAX_IDLE_TIME", 15*time.Minute),
|
||||
@@ -92,6 +97,12 @@ func configFromEnvironment() (api.Config, error) {
|
||||
if cfg.Env == "production" && !cfg.Session.CookieSecure {
|
||||
errs = append(errs, errors.New("GARDOMATIC_COOKIE_SECURE must be true in production"))
|
||||
}
|
||||
if cfg.DemoAccountEmail != "" {
|
||||
v := validate.New()
|
||||
if storage.ValidateEmail(v, cfg.DemoAccountEmail); !v.Valid() {
|
||||
errs = append(errs, errors.New("GARDOMATIC_DEMO_ACCOUNT_EMAIL must be a valid email address"))
|
||||
}
|
||||
}
|
||||
if _, err := mailer.New(cfg.Mail); err != nil {
|
||||
errs = append(errs, fmt.Errorf("mail configuration: %w", err))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user