package config

import (
	"github.com/caarlos0/env/v11"
)

type Config struct {
	Environment     string `env:"ENVIRONMENT" envDefault:"production"`
	DbDataDir       string `env:"CCTV_PB_DATA_DIR" envDefault:"./pb_data"`
	DbEncryptionKey string `env:"CCTV_PB_ENCRYPTION_KEY" envDefault:""`
	RecordingsDir   string `env:"CCTV_REC_DIR" envDefault:"./recordings"`
	ExternalWebApp  string `env:"CCTV_EXTERNAL_WEB_APP" envDefault:""`
}

func Load() (*Config, error) {
	var cfg Config
	if err := env.ParseWithOptions(&cfg, env.Options{
		RequiredIfNoDef: true,
	}); err != nil {
		return nil, err
	}
	return &cfg, nil
}

func (c *Config) IsDev() bool {
	return c.Environment == "development"
}
