merch-api/config/config.go

67 lines
1.2 KiB
Go
Raw Normal View History

2026-02-23 18:34:26 +03:00
package config
import "time"
type Config struct {
App App
Http Http
TasksSource TasksSource
2026-02-23 20:22:21 +03:00
DBase DBase
2026-02-23 18:34:26 +03:00
}
type App struct {
LogLvl string
2026-02-23 19:33:36 +03:00
Mode string
2026-02-23 18:34:26 +03:00
}
type Http struct {
Host string
Port string
2026-02-23 19:33:36 +03:00
Prefix string
2026-02-23 18:34:26 +03:00
GinMode string
}
type TasksSource struct {
Host string
Port string
Timeout time.Duration
}
2026-02-23 20:22:21 +03:00
type DBase struct {
Host string
Port string
Username string
Password string
DBName string
}
2026-02-23 18:34:26 +03:00
func NewConfig() Config {
return Config{
App: App{
LogLvl: getEnv("APP_LOG_LVL", "debug"),
2026-02-23 19:33:36 +03:00
Mode: getEnv("APP_MODE", "dev"),
2026-02-23 18:34:26 +03:00
},
Http: Http{
Host: getEnv("HTTP_HOST", "0.0.0.0"),
2026-02-23 19:33:36 +03:00
Port: getEnv("HTTP_PORT", "41083"),
Prefix: getEnv("HTTP_PREFIX", "/api/v2"),
2026-02-23 18:34:26 +03:00
GinMode: getEnv("GIN_MODE", "dev"),
},
TasksSource: TasksSource{
Host: getEnv("TASK_API_HOST", "127.0.0.1"),
Port: getEnv("TASK_API_PORT", "61000"),
Timeout: getEnvSeconds("TASK_SOURCE_TIMEOUT_SECONDS", 60),
},
2026-02-23 20:22:21 +03:00
DBase: DBase{
Host: getEnv("DB_HOST", "10.0.0.4"),
Port: getEnv("DB_PORT", "54326"),
Username: getEnv("DB_USERNAME", "merch_app_user"),
Password: getEnv("DB_PASSWORD", "7kek8wait9"),
DBName: getEnv("DB_NAME", "merch_dev"),
},
2026-02-23 18:34:26 +03:00
}
}