implement payroll generator v0.9

This commit is contained in:
Marcel Arndt
2025-11-06 11:38:59 +01:00
parent 319e7f3614
commit 4abe9e44d8
27 changed files with 4273 additions and 0 deletions
@@ -0,0 +1,39 @@
package config
import (
"fmt"
"strings"
"github.com/spf13/viper"
)
type Config struct {
Port string
LogLevel string
DatabaseURL string `mapstructure:"databaseUrl"`
// SurchargeRules []models.SurchargeRule `mapstructure:"surchargeRules"`
}
func Load() (*Config, error) {
viper.AddConfigPath(".")
viper.AddConfigPath("/etc/business-engine/")
viper.SetConfigName("config")
viper.SetConfigType("yaml")
viper.AutomaticEnv()
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
if err := viper.ReadInConfig(); err != nil {
if _, ok := err.(viper.ConfigFileNotFoundError); !ok {
return nil, fmt.Errorf("failed to read config file: %w", err)
}
}
viper.BindEnv("databaseUrl", "DATABASE_URL")
var cfg Config
if err := viper.Unmarshal(&cfg); err != nil {
return nil, fmt.Errorf("failed to unmarshal config: %w", err)
}
return &cfg, nil
}