package config

import "os"

type Config struct {
	MongoURL    string
	MongoDBName string
	LocalURL    string
	ProdURL     string
	// RUN_DELIVERY_ON_START=true runs the hourly delivery job once at startup, for testing
	RunDeliveryOnStart bool

	// error alert mail, sent after a cron run which logged errors
	AlertSMTPHost string
	AlertFrom     string
	AlertPassword string
	AlertTo       string
}

func Load() Config {
	return Config{
		MongoURL:    os.Getenv("MONGO_URI"),
		MongoDBName: os.Getenv("MONGO_DB_NAME"),
		LocalURL:    os.Getenv("LOCAL_URL"),
		ProdURL:     os.Getenv("PROD_URL"),

		RunDeliveryOnStart: os.Getenv("RUN_DELIVERY_ON_START") == "true",

		AlertSMTPHost: os.Getenv("ALERT_SMTP_HOST"),
		AlertFrom:     os.Getenv("ALERT_FROM_EMAIL"),
		AlertPassword: os.Getenv("ALERT_FROM_PASSWORD"),
		AlertTo:       os.Getenv("ALERT_TO_EMAIL"),
	}
}
