26 lines
636 B
Go
26 lines
636 B
Go
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/caarlos0/env"
|
|
)
|
|
|
|
type Config struct {
|
|
E621APIKey string `env:"E621_API_KEY,required"`
|
|
E621Username string `env:"E621_USERNAME,required"`
|
|
DBType string `env:"DB_TYPE,required"`
|
|
DBEndpoint string `env:"DB_URL,required"`
|
|
DBUsername string `env:"DB_USERNAME,required"`
|
|
DBPassword string `env:"DB_PASSWORD,required"`
|
|
}
|
|
|
|
// LoadConfig loads the configuration from environment variables
|
|
func LoadConfig() (*Config, error) {
|
|
config := &Config{}
|
|
if err := env.Parse(config); err != nil {
|
|
return nil, fmt.Errorf("error parsing configuration: %w", err)
|
|
}
|
|
|
|
return config, nil
|
|
}
|