config

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindEnvTest added in v1.3.0

func FindEnvTest(filename string) (string, error)

FindEnvTest searches for the nearest file If filename is empty, it searches for .env

Types

type App

type App struct {
	Env                      string                 `envconfig:"APP_ENV" default:"development"`
	Server                   *Server                `envconfig:"SERVER"`
	Log                      *Log                   `envconfig:"LOG"`
	DB                       *DB                    `envconfig:"DATABASE"`
	Auth                     *Auth                  `envconfig:"AUTH"`
	ExchangeRateCache        *ExchangeRateCache     `envconfig:"EXCHANGE_RATE_CACHE"`
	ExchangeRateAPIProviders *ExchangeRateProviders `envconfig:"EXCHANGE_RATE_PROVIDER"`
	Redis                    *Redis                 `envconfig:"REDIS"`
	EventBus                 *EventBus              `envconfig:"EVENT_BUS"`
	RateLimit                *RateLimit             `envconfig:"RATE_LIMIT"`
	PaymentProviders         *PaymentProviders      `envconfig:"PAYMENT_PROVIDER"`
	Fee                      *Fee                   `envconfig:"FEE"`
}

func Load

func Load(envFilePath ...string) (*App, error)

type Auth

type Auth struct {
	Strategy string `envconfig:"STRATEGY" default:"jwt"`
	Jwt      *Jwt   `envconfig:"JWT"`
}

type DB

type DB struct {
	Url string `envconfig:"URL"`
}

type Deps

type Deps struct {
	Uow                          repository.UnitOfWork
	ExchangeRateProvider         exchange.Exchange
	ExchangeRateRegistryProvider registry.Provider
	CurrencyRegistry             registry.Provider
	PaymentProvider              payment.Payment
	EventBus                     eventbus.Bus
	Logger                       *slog.Logger
	Config                       *App
}

Deps holds all infrastructure dependencies for building the app and services.

type EventBus added in v1.5.3

type EventBus struct {
	Driver       string `envconfig:"DRIVER" default:""`
	RedisURL     string `envconfig:"REDIS_URL" default:""`
	KafkaBrokers string `envconfig:"KAFKA_BROKERS" default:""`
	KafkaTopic   string `envconfig:"KAFKA_TOPIC" default:"fintech.events"`
	KafkaGroupID string `envconfig:"KAFKA_GROUP_ID" default:"fintech"`
}

type ExchangeRateApi added in v1.3.0

type ExchangeRateApi struct {
	ApiKey      string        `envconfig:"API_KEY"`
	ApiUrl      string        `envconfig:"API_URL" default:""`
	HTTPTimeout time.Duration `envconfig:"HTTP_TIMEOUT" default:"10s"`
}

type ExchangeRateCache added in v1.3.0

type ExchangeRateCache struct {
	TTL               time.Duration `envconfig:"TTL" default:"15m"`
	MaxRetries        int           `envconfig:"MAX_RETRIES" default:"3"`
	RequestsPerMinute int           `envconfig:"REQUESTS_PER_MINUTE" default:"60"`
	BurstSize         int           `envconfig:"BURST_SIZE" default:"10"`
	EnableFallback    bool          `envconfig:"ENABLE_FALLBACK" default:"true"`
	FallbackTTL       time.Duration `envconfig:"FALLBACK_TTL" default:"1h"`
	Prefix            string        `envconfig:"CACHE_PREFIX" default:"exr:rate:"`
	Url               string        `envconfig:"URL"`
}

type ExchangeRateProviders added in v1.3.0

type ExchangeRateProviders struct {
	ExchangeRateApi *ExchangeRateApi `envconfig:"EXCHANGERATE"`
}

type Fee

type Fee struct {
	ServiceFeePercentage float64 `envconfig:"SERVICE_FEE_PERCENTAGE" default:"0.01"`
}

type Jwt

type Jwt struct {
	Secret string        `envconfig:"SECRET" required:"true"`
	Expiry time.Duration `envconfig:"EXPIRY" default:"24h"`
}

type Log

type Log struct {
	Level      int    `envconfig:"LEVEL" default:"0"`
	Format     string `envconfig:"FORMAT" default:"json"`
	TimeFormat string `envconfig:"TIME_FORMAT" default:"2006-01-02 15:04:05"`
	Prefix     string `envconfig:"PREFIX" default:"[fintech]"`
}

type PaymentProviders

type PaymentProviders struct {
	Stripe *Stripe `envconfig:"STRIPE"`
}

type RateLimit

type RateLimit struct {
	MaxRequests int           `envconfig:"MAX_REQUESTS" default:"100"`
	Window      time.Duration `envconfig:"WINDOW" default:"1m"`
}

type Redis

type Redis struct {
	URL          string        `envconfig:"URL" default:"redis://localhost:6379/0"`
	KeyPrefix    string        `envconfig:"KEY_PREFIX" default:""`
	PoolSize     int           `envconfig:"POOL_SIZE" default:"10"`
	DialTimeout  time.Duration `envconfig:"DIAL_TIMEOUT" default:"5s"`
	ReadTimeout  time.Duration `envconfig:"READ_TIMEOUT" default:"3s"`
	WriteTimeout time.Duration `envconfig:"WRITE_TIMEOUT" default:"3s"`
}

type Server

type Server struct {
	Scheme string `envconfig:"SCHEME" default:"http"`
	Host   string `envconfig:"HOST" default:"localhost"`
	Port   int    `envconfig:"PORT" default:"3000"`
}

type Stripe

type Stripe struct {
	Env                  string `envconfig:"ENV" default:"test oneof(test, development, production)"`
	ApiKey               string `envconfig:"API_KEY"`
	SigningSecret        string `envconfig:"SIGNING_SECRET"`
	SuccessPath          string `envconfig:"SUCCESS_PATH" default:"http://localhost:3000/payment/stripe/success/"`
	CancelPath           string `envconfig:"CANCEL_PATH" default:"http://localhost:3000/payment/stripe/cancel/"`
	OnboardingReturnURL  string `envconfig:"ONBOARDING_RETURN_URL" default:"http://localhost:3000/onboarding/return"`
	OnboardingRefreshURL string `envconfig:"ONBOARDING_REFRESH_URL" default:"http://localhost:3000/onboarding/refresh"`
	SkipTLSVerify        bool   `envconfig:"SKIP_TLS_VERIFY" default:"false"` // Skip TLS verification for development
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL