diff options
Diffstat (limited to 'internal/config/config.go')
| -rw-r--r-- | internal/config/config.go | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index 62e733a..cf3af49 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -9,10 +9,11 @@ import ( // Config holds all application configuration type Config struct { // API Keys - TodoistAPIKey string - PlanToEatAPIKey string - TrelloAPIKey string - TrelloToken string + TodoistAPIKey string + PlanToEatAPIKey string + PlanToEatSession string // Session cookie for web scraping + TrelloAPIKey string + TrelloToken string // Google Calendar GoogleCredentialsFile string @@ -28,16 +29,20 @@ type Config struct { Port string CacheTTLMinutes int Debug bool + + // Display + Timezone string // IANA timezone name (e.g., "Pacific/Honolulu") } // Load reads configuration from environment variables func Load() (*Config, error) { cfg := &Config{ // API Keys - TodoistAPIKey: os.Getenv("TODOIST_API_KEY"), - PlanToEatAPIKey: os.Getenv("PLANTOEAT_API_KEY"), - TrelloAPIKey: os.Getenv("TRELLO_API_KEY"), - TrelloToken: os.Getenv("TRELLO_TOKEN"), + TodoistAPIKey: os.Getenv("TODOIST_API_KEY"), + PlanToEatAPIKey: os.Getenv("PLANTOEAT_API_KEY"), + PlanToEatSession: os.Getenv("PLANTOEAT_SESSION"), + TrelloAPIKey: os.Getenv("TRELLO_API_KEY"), + TrelloToken: os.Getenv("TRELLO_TOKEN"), // Google Calendar GoogleCredentialsFile: os.Getenv("GOOGLE_CREDENTIALS_FILE"), @@ -53,6 +58,9 @@ func Load() (*Config, error) { Port: getEnvWithDefault("PORT", "8080"), CacheTTLMinutes: getEnvAsInt("CACHE_TTL_MINUTES", 5), Debug: getEnvAsBool("DEBUG", false), + + // Display + Timezone: getEnvWithDefault("TIMEZONE", "Pacific/Honolulu"), } // Validate required fields @@ -81,9 +89,14 @@ func (c *Config) Validate() error { return nil } -// HasPlanToEat checks if PlanToEat is configured +// HasPlanToEat checks if PlanToEat is configured (API key or session) func (c *Config) HasPlanToEat() bool { - return c.PlanToEatAPIKey != "" + return c.PlanToEatAPIKey != "" || c.PlanToEatSession != "" +} + +// HasPlanToEatSession checks if PlanToEat session cookie is configured +func (c *Config) HasPlanToEatSession() bool { + return c.PlanToEatSession != "" } // HasTrello checks if Trello is configured |
